Skip to content

Commit

Permalink
fix: db teardown for data mutation tests (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrunton authored Aug 26, 2024
1 parent e86c35d commit 3790af8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion services/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
"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",
"test:watch": "jest --watch",
"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"
Expand Down
5 changes: 5 additions & 0 deletions services/api/src/fixtures/setup-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions services/api/src/fixtures/teardown-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3790af8

Please sign in to comment.