Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit c24bc8a

Browse files
committed
Added jest support
The placement of test files is the same as in vue-storefront "src/**/test/unit/**/*.spec.(js|ts)".
1 parent ccf5769 commit c24bc8a

File tree

3 files changed

+1830
-31
lines changed

3 files changed

+1830
-31
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"migrate": "node node_modules/migrate/bin/migrate",
3232
"prestart": "npm run -s build",
3333
"test": "eslint src",
34+
"test:unit": "jest -c test/unit/jest.conf.js",
3435
"setup": "npm run restore; npm run migrate",
3536
"lint": "eslint --ext .js src migrations scripts"
3637
},
@@ -100,11 +101,14 @@
100101
"@types/body-parser": "^1.17.0",
101102
"@types/config": "^0.0.34",
102103
"@types/express": "^4.16.1",
104+
"@types/jest": "^24.0.11",
103105
"@types/node": "^11.13.4",
104106
"apollo-server-express": "^1.3.6",
105107
"cpx": "^1.5.0",
106108
"eslint": "^4.16.0",
109+
"jest": "^24.8.0",
107110
"nodemon": "^1.18.7",
111+
"ts-jest": "^24.0.2",
108112
"ts-node": "^8.1.0",
109113
"tslib": "^1.9.3",
110114
"typescript": "3.3.*"

test/unit/jest.conf.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
rootDir: '../../',
3+
moduleFileExtensions: [
4+
'js',
5+
'ts',
6+
'json'
7+
],
8+
testMatch: [
9+
'<rootDir>/src/**/test/unit/**/*.spec.(js|ts)',
10+
],
11+
transform: {
12+
'^.+\\.js$': '<rootDir>/node_modules/ts-jest',
13+
'^.+\\.ts$': '<rootDir>/node_modules/ts-jest',
14+
},
15+
coverageDirectory: '<rootDir>/test/unit/coverage',
16+
collectCoverageFrom: [
17+
'src/**/*.{js,ts}',
18+
'!src/**/types/*.{js,ts}',
19+
],
20+
moduleNameMapper: {
21+
'^src(.*)$': '<rootDir>/src$1'
22+
},
23+
transformIgnorePatterns: [
24+
'<rootDir>/node_modules/(?!lodash)'
25+
]
26+
}

0 commit comments

Comments
 (0)