diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7ce2846..6e3d944 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,8 +25,8 @@ jobs: - name: Build application run: yarn build - - name: Run tests - run: yarn test + - name: Run unit tests + run: yarn test:unit cloud_build: needs: build_and_test diff --git a/jest.config.integration.ts b/jest.config.integration.ts new file mode 100644 index 0000000..0e1a2da --- /dev/null +++ b/jest.config.integration.ts @@ -0,0 +1,9 @@ +import baseConfig from "./jest.config" +import { type Config } from "jest"; + +const config: Config = { + ...baseConfig, + testRegex: ".*\\.integration\\.spec\\.ts$", +} + +export default config; \ No newline at end of file diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 0000000..61d0768 --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,24 @@ +import { type Config } from "jest"; + +const config: Config = { + moduleFileExtensions: [ + "js", + "json", + "ts" + ], + rootDir: ".", + transform: { + "^.+\\.(t|j)s$": "ts-jest" + }, + testEnvironment: "node", + roots: [ + "/src/" + ], + moduleDirectories: [ + "node_modules", + "src" + ], + setupFiles: ["./src/preStart.ts"] +} + +export default config; \ No newline at end of file diff --git a/jest.config.unit.ts b/jest.config.unit.ts new file mode 100644 index 0000000..4b9ae5b --- /dev/null +++ b/jest.config.unit.ts @@ -0,0 +1,9 @@ +import baseConfig from "./jest.config" +import { type Config } from "jest"; + +const config: Config = { + ...baseConfig, + testRegex: ".*\\.unit\\.spec\\.ts$", +} + +export default config; \ No newline at end of file diff --git a/package.json b/package.json index bc6e3ec..9cdc417 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "build": "run-s clean generate-api-types compile copy-resources", "lint": "eslint --ext .ts src/", "dev": "nodemon src/server.ts", - "test": "jest" + "test:unit": "jest --config \"jest.config.unit.ts\"", + "test:integration": "jest --config \"jest.config.integration.ts\"" }, "dependencies": { "@types/supertest": "^2.0.12", @@ -60,26 +61,5 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.1.2", "typescript": "^5.0.3" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": ".", - "testRegex": ".*\\.spec\\.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "testEnvironment": "node", - "roots": [ - "/src/" - ], - "moduleDirectories": [ - "node_modules", - "src" - ], - "setupFiles": ["./src/preStart.ts"] } } diff --git a/src/preStart.ts b/src/preStart.ts index f87eb09..cf83ef3 100644 --- a/src/preStart.ts +++ b/src/preStart.ts @@ -19,13 +19,16 @@ interface Args { // **** Setup **** // // Command line arguments -const args = parse({ - env: { - type: String, - defaultValue: process.env.NODE_ENV ?? "development", - alias: "e", +const args = parse( + { + env: { + type: String, + defaultValue: process.env.NODE_ENV ?? "development", + alias: "e", + }, }, -}); + { partial: true } +); // Set the env file const dotenvConfig = dotenv.config({ diff --git a/src/routes/budget/budgetRouter.integration.spec.excluded.ts b/src/routes/budget/budgetRouter.integration.spec.ts similarity index 100% rename from src/routes/budget/budgetRouter.integration.spec.excluded.ts rename to src/routes/budget/budgetRouter.integration.spec.ts