Skip to content

Commit 6bc8b64

Browse files
committed
Config Jest
- Added Jest config file. - Set ESLint to ignore Jest config file. - Config TypeScript to not treat files in `test` folder as part of the source code.
1 parent edd62ff commit 6bc8b64

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ node_modules
22
dist
33
out
44
public
5+
jest.config.js
56
webpack.config.js

jest.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { pathsToModuleNameMapper } = require('ts-jest')
2+
const { compilerOptions } = require('./tsconfig.json')
3+
4+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
5+
module.exports = config = {
6+
testEnvironment: 'node',
7+
globals: {
8+
'ts-test': {
9+
tsconfig: 'tsconfig.json'
10+
}
11+
},
12+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
13+
moduleNameMapper: pathsToModuleNameMapper(
14+
compilerOptions.paths,
15+
{ prefix: '<rootDir>/' }
16+
),
17+
transform: {
18+
'^.+\\.(ts|tsx)$': 'ts-jest'
19+
},
20+
testMatch: [
21+
'**/tests/**/*.test.(ts?(x)|js?(x))'
22+
],
23+
verbose: true,
24+
};

test/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": true
5+
},
6+
"include": ["./**/*"]
7+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
"sourceMap": true,
2020
"target": "esnext"
2121
},
22-
"exclude": ["node_modules"]
22+
"include": ["src/**/*"]
2323
}

0 commit comments

Comments
 (0)