Skip to content

Commit 38146bd

Browse files
committed
Migrate from Mocha to Jest
1 parent 53f7b74 commit 38146bd

78 files changed

Lines changed: 43292 additions & 39915 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ dist/
33
types/
44
/test/restDocs/*.json
55
/test/restDocs/results/
6-
/test/restDocs/snapshots/

.eslintrc.cjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,5 @@ module.exports = {
1111
sourceType: 'module',
1212
project: './tsconfig.json',
1313
},
14-
env: {
15-
mocha: true,
16-
},
1714
root: true,
1815
};

.mocharc.json

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

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
/test/*cache.json
55
/test/restDocs/*.json
66
/test/restDocs/results/
7-
/test/restDocs/snapshots/

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ GAPI_MAX_PARALLEL=3 npm run lint
118118
119119
#### Unit (WIP)
120120
121-
Unit tests for this generator project are written with [Jasmine](https://jasmine.github.io/) and
122-
[Mocha](https://mochajs.org/). They can be run via:
121+
Unit tests for this generator project are written with [Jest](https://jestjs.io/). They can be run via:
123122
124123
```sh
125124
npm run test

bin/cspell.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ const files = (await sh.runSh('npx -y ls-ignore --paths')).stdout
66
.filter(x => x.trim() !== '')
77
.filter(x => !(x.startsWith('test/restDocs') && x.endsWith('.json')))
88
.filter(x => !x.startsWith('test/restDocs/results/'))
9-
.filter(x => !x.startsWith('test/restDocs/snapshots/'));
9+
.filter(x => !x.startsWith('test/restDocs/__snapshots__/'));
1010
await sh.runSh(`npx -y cspell ${files.join(' ')}`);

jest.config.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {JestConfigWithTsJest} from 'ts-jest';
2+
import {defaultsESM} from 'ts-jest/presets';
3+
4+
const defaultsESMPatched = defaultsESM;
5+
// TODO: remove the following once https://github.com/kulshekhar/ts-jest/pull/3833 is released
6+
defaultsESMPatched.transform!['^.+\\.tsx?$'] = ['ts-jest', {useESM: true}];
7+
// TODO: remove the following once https://github.com/kulshekhar/ts-jest/pull/3833 is released
8+
defaultsESMPatched.extensionsToTreatAsEsm =
9+
defaultsESMPatched.extensionsToTreatAsEsm?.filter(x => x !== '.mts');
10+
11+
const config: JestConfigWithTsJest = {
12+
...defaultsESMPatched,
13+
moduleNameMapper: {
14+
'^(\\.{1,2}/.*)\\.js$': '$1',
15+
},
16+
testRegex: '/test/.*(?<!\\.integration)\\.spec\\.ts$',
17+
};
18+
19+
export default config;

jest.integration.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {JestConfigWithTsJest} from 'ts-jest';
2+
import defaultConfig from './jest.config';
3+
4+
const config: JestConfigWithTsJest = {
5+
...defaultConfig,
6+
testRegex: '/test/.*\\.integration\\.spec\\.ts$',
7+
};
8+
9+
export default config;

0 commit comments

Comments
 (0)