diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8b130501..24963ec2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -120,7 +120,7 @@ jobs: with: port: 8001 - run: pnpm --filter api install - - run: pnpm run --filter api db:init + - run: pnpm run --filter api db:test:init - run: pnpm --filter api run test:mutate:data build-api: diff --git a/services/api/package.json b/services/api/package.json index 64f16c83..01ace0d7 100644 --- a/services/api/package.json +++ b/services/api/package.json @@ -18,6 +18,7 @@ "start:debug": "NODE_ENV=development nest start --debug --watch", "db:init": "NODE_ENV=development ts-node ./scripts/db/init.ts", "db:drop": "NODE_ENV=development ts-node ./scripts/db/drop.ts", + "db:test:init": "NODE_ENV=test ts-node ./scripts/db/init.ts", "db:test:drop": "NODE_ENV=test ts-node ./scripts/db/drop.ts", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix --max-warnings 0", "test": "jest", @@ -25,7 +26,7 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:mutate": "stryker run", - "test:mutate:data": "stryker run stryker.data.conf.mjs", + "test:mutate:data": "NODE_ENV=test SKIP_DB_SETUP=true stryker run stryker.data.conf.mjs", "test:int": "jest --config ./test/jest-e2e.config.cjs", "docs:generate": "typedoc", "docs:serve": "http-server docs" diff --git a/services/api/src/fixtures/setup-e2e.ts b/services/api/src/fixtures/setup-e2e.ts index 63fb2de3..ab625ebb 100644 --- a/services/api/src/fixtures/setup-e2e.ts +++ b/services/api/src/fixtures/setup-e2e.ts @@ -5,6 +5,11 @@ import { Test, TestingModule } from '@nestjs/testing'; import { LoggerModule } from '@app/app.logger'; const setup = async () => { + // Setup and teardown should be done manually for mutation tests + if (process.env.SKIP_DB_SETUP === 'true') { + return; + } + const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [DataModule, LoggerModule], }).compile(); diff --git a/services/api/src/fixtures/teardown-e2e.ts b/services/api/src/fixtures/teardown-e2e.ts index 8ff37cdd..e5dfad2b 100644 --- a/services/api/src/fixtures/teardown-e2e.ts +++ b/services/api/src/fixtures/teardown-e2e.ts @@ -5,6 +5,11 @@ import { Test, TestingModule } from '@nestjs/testing'; import { LoggerModule } from '@app/app.logger'; const setup = async () => { + // Setup and teardown should be done manually for mutation tests + if (process.env.SKIP_DB_SETUP === 'true') { + return; + } + const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [DataModule, LoggerModule], }).compile();