Skip to content

Commit 88da5c4

Browse files
authored
use separate config files for unit and e2e tests (#193)
* use separate config files for unit and e2e tests
1 parent 23edd47 commit 88da5c4

File tree

5 files changed

+44
-30
lines changed

5 files changed

+44
-30
lines changed

jest.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @returns {Promise<import('jest').Config>} */
2+
module.exports = async () => {
3+
return {
4+
projects: ['./test/jest.config.ts', './src/jest.config.ts'],
5+
roots: ['./'],
6+
testTimeout: 30000,
7+
};
8+
};

package.json

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"start:debug": "nest start --debug --watch",
1515
"start:prod": "node dist/main",
1616
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
17-
"test": "jest",
18-
"test:watch": "jest --watch",
19-
"test:cov": "jest --coverage",
20-
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
21-
"test:e2e": "jest --config ./test/jest-e2e.json"
17+
"test": "jest --projects src",
18+
"test:watch": "jest --projects src --watch",
19+
"test:cov": "jest --projects src --coverage",
20+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --projects src --runInBand",
21+
"test:e2e": "jest --projects test"
2222
},
2323
"dependencies": {
2424
"@nestjs/common": "^8.4.1",
@@ -32,7 +32,7 @@
3232
"@nestjs/swagger": "^5.2.0",
3333
"@nestjs/terminus": "^8.0.8",
3434
"@nestjs/websockets": "^8.4.1",
35-
"@prisma/client": "^2.12.1",
35+
"@prisma/client": "2.12.1",
3636
"ajv": "^8.10.0",
3737
"bcryptjs": "^2.4.3",
3838
"cache-manager": "^3.6.0",
@@ -86,19 +86,5 @@
8686
"ts-node": "^10.7.0",
8787
"tsconfig-paths": "^3.14.0",
8888
"typescript": "^4.6.2"
89-
},
90-
"jest": {
91-
"moduleFileExtensions": [
92-
"js",
93-
"json",
94-
"ts"
95-
],
96-
"rootDir": "src",
97-
"testRegex": ".spec.ts$",
98-
"transform": {
99-
"^.+\\.(t|j)s$": "ts-jest"
100-
},
101-
"coverageDirectory": "../coverage",
102-
"testEnvironment": "node"
10389
}
10490
}

src/jest.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** @returns {Promise<import('jest').Config>} */
2+
module.exports = async () => {
3+
return {
4+
name: 'unit',
5+
displayName: 'Unit Tests',
6+
roots: ['./'],
7+
moduleFileExtensions: ['js', 'json', 'ts'],
8+
transform: {
9+
'^.+\\.(t|j)s$': 'ts-jest',
10+
},
11+
coverageDirectory: '../coverage',
12+
testEnvironment: 'node',
13+
};
14+
};

test/jest-e2e.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/jest.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @returns {Promise<import('jest').Config>} */
2+
module.exports = async () => {
3+
return {
4+
name: 'e2e',
5+
displayName: 'E2E Tests',
6+
roots: ['./'],
7+
testTimeout: 30000,
8+
testRegex: '.e2e-spec.ts$',
9+
moduleFileExtensions: ['js', 'json', 'ts'],
10+
transform: {
11+
'^.+\\.(t|j)s$': 'ts-jest',
12+
},
13+
coverageDirectory: '../coverage',
14+
testEnvironment: 'node',
15+
};
16+
};

0 commit comments

Comments
 (0)