Skip to content

Commit

Permalink
feat: setup jest for unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisam committed Oct 29, 2024
1 parent a3ad235 commit de2d867
Show file tree
Hide file tree
Showing 5 changed files with 1,945 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ meta.json
stats.html

test-workspace/
.vscode/my-folders.json
coverage/
22 changes: 22 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
rootDir: './',
testMatch: ['<rootDir>/src/**/*.test.ts'],
testEnvironment: 'node',
transform: {
'^.+.ts$': ['ts-jest', { tsconfig: '<rootDir>/src/tsconfig.test.json' }],
},
verbose: true,
collectCoverage: true,
modulePathIgnorePatterns: ['<rootDir>/dist/'],
collectCoverage: true,
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
maxWorkers: 2,
};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"esbuild:analyze": "pnpm esbuild:base --minify --metafile --analyze && esbuild-visualizer --metadata ./meta.json --open",
"compile:test": "pnpm clean && tsc -b ./test/tsconfig.json",
"lint": "eslint src --ext ts",
"test": "stale-dep && pnpm compile:test && node ./out/test/runTests.js",
"test": "pnpm compile:test && node ./out/test/runTests.js",
"package": "vsce package --no-dependencies",
"release": "npx @yutengjing/release",
"publish:vs-marketplace": "vsce publish --no-dependencies",
Expand All @@ -188,6 +188,7 @@
"devDependencies": {
"@npmcli/promise-spawn": "^8.0.2",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.14",
"@types/mocha": "^10.0.9",
"@types/node": "~20.17.1",
"@types/npmcli__promise-spawn": "^6.0.3",
Expand All @@ -201,13 +202,15 @@
"esbuild-visualizer": "^0.6.0",
"eslint": "^8.57.1",
"glob": "^11.0.0",
"jest": "^29.7.0",
"lint-staged": "^15.2.10",
"mocha": "^10.7.3",
"ovsx": "^0.10.0",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"simple-git-hooks": "^2.11.1",
"stale-dep": "^0.7.0",
"ts-jest": "^29.2.5",
"tsx": "^4.19.1",
"typescript": "~5.6.3"
}
Expand Down
Loading

0 comments on commit de2d867

Please sign in to comment.