Skip to content

Commit

Permalink
Initial version of Witcher API tester
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerii Maslenykov authored and ValeriyMaslenikov committed Aug 14, 2023
0 parents commit 4679a5a
Show file tree
Hide file tree
Showing 46 changed files with 14,427 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true
}
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# TODO: Test
name: Publish Package to npmjs

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"

- name: Git configuration
run: |
git config --global user.email "code@getjoystick.com"
git config --global user.name "GitHub Actions"
- name: Install dependencies
run: npm ci

- name: Run eslint and prettier check
run: npm run lint

- name: Build
run: npm run build

- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Verify build

on:
push:

jobs:
verification:
name: "Verify build (lint + build + tests)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Run CI
run: npm ci
- name: Run Lint
run: npm run lint
- name: Run Build
run: npm run build

- name: Shutdown pre-installed Ubuntu MySQL
run: sudo service mysql stop
- name: Run MySQL server for running test
uses: mirromutth/mysql-action@v1.1
with:
mysql version: "5.7"
mysql database: "dbname"
mysql user: "user"
mysql password: "password"
- name: Wait for MySQL
run: |
while ! mysqladmin ping --host=127.0.0.1 --password=password --user=user --silent; do
sleep 1
done
- name: Run Test
run: npm run test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules

.DS_Store
.idea

joystick-*
tests-json/secrets/**/*
dist/
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"printWidth": 120
}
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "node",
"request": "launch",
"args": ["src/index.mts"],
"runtimeArgs": ["--loader", "ts-node/esm"],
"console": "integratedTerminal",
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2023-08-14

### Added

- Interactive mode to visually select configuration for the test
- Non-interactive mode to run the application in CI environment
- Joystick as a data-source for testing configurations and devs collaboration
- Structure of configurations files
- Dedicated files structure to store secrets needed for tests (e.g. database credentials)
- Variables shared between test steps
- Assertions based on responses and changes in the database
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.3"
services:
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: "dbname"
MYSQL_USER: "user"
MYSQL_PASSWORD: "password"
MYSQL_ROOT_PASSWORD: "password"
ports:
- "3306:3306"
expose:
- "3306"
19 changes: 19 additions & 0 deletions jest.common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { JestConfigWithTsJest } from "ts-jest";

export default {
testEnvironment: "node",
preset: "ts-jest/presets/default-esm", // or other ESM presets
extensionsToTreatAsEsm: [".ts", ".mts"],
moduleFileExtensions: ["ts", "mts", "js", "json"],
transform: {
"^.+\\.mts$": [
"ts-jest",
{
useESM: true,
},
],
},
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.m?js$": "$1",
},
} as JestConfigWithTsJest;
6 changes: 6 additions & 0 deletions jest.integration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import jestCommon from "./jest.common";

export default {
...jestCommon,
testRegex: "integration.(test|spec).mts",
};
6 changes: 6 additions & 0 deletions jest.unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import jestCommon from "./jest.common";

export default {
...jestCommon,
testRegex: "unit.(test|spec).mts",
};
7 changes: 7 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"watch": ["src"],
"ext": ".ts,.js,.mts,.mjs",
"ignore": [],
"exec": "node --inspect --loader ts-node/esm ./src/index.mts",
"restartable": false
}
Loading

0 comments on commit 4679a5a

Please sign in to comment.