Skip to content

Commit 2317224

Browse files
committed
Set up Jest testing framework
1 parent 407d388 commit 2317224

File tree

7 files changed

+63
-4331
lines changed

7 files changed

+63
-4331
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ dist
33
coverage
44
**/*.d.ts
55
tests
6-
_temp_extension
6+
_temp_extension

babel.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current'
8+
}
9+
}
10+
]
11+
]
12+
};

jest.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import path = require('path');
2+
3+
const config = function(baseDir: string) {
4+
return {
5+
preset: 'ts-jest/presets/js-with-babel',
6+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7+
transformIgnorePatterns: ['/node_modules/(?!(@jupyterlab/.*)/)'],
8+
reporters: ['default', 'jest-junit', 'jest-summary-reporter'],
9+
coverageReporters: ['json', 'lcov', 'text', 'html'],
10+
coverageDirectory: path.join(baseDir, 'coverage'),
11+
testRegex: '/test/.*.ts[x]?$',
12+
globals: {
13+
'ts-jest': {
14+
tsConfig: 'tsconfig.test.json'
15+
}
16+
}
17+
};
18+
};
19+
20+
module.exports = config(__dirname);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"eslint-plugin-prettier": "^3.1.2",
7676
"eslint-plugin-react": "^7.20.4",
7777
"husky": "^4.2.5",
78+
"jest": "^24",
7879
"lint-staged": "^10.2.13",
7980
"mkdirp": "^1.0.3",
8081
"npm-run-all": "^4.1.5",

test/test.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test('two plus two is four', () => {
2+
expect(2 + 2).toBe(4);
3+
});

tsconfig.test.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"noImplicitAny": true,
5+
"noEmitOnError": true,
6+
"noUnusedLocals": true,
7+
"module": "commonjs",
8+
"moduleResolution": "node",
9+
"target": "es2015",
10+
"outDir": "lib",
11+
"lib": [
12+
"es2015",
13+
"es2015.collection",
14+
"dom",
15+
"es2015.iterable",
16+
"es2017.object"
17+
],
18+
"types": ["jest", "node"],
19+
"jsx": "react",
20+
"resolveJsonModule": true,
21+
"esModuleInterop": true,
22+
"strictNullChecks": true,
23+
"skipLibCheck": true
24+
},
25+
"include": ["src/*", "test/*"]
26+
}

0 commit comments

Comments
 (0)