Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Mocha to Jest #706

Merged
merged 2 commits into from Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -3,4 +3,3 @@ dist/
types/
/test/restDocs/*.json
/test/restDocs/results/
/test/restDocs/snapshots/
3 changes: 0 additions & 3 deletions .eslintrc.cjs
Expand Up @@ -11,8 +11,5 @@ module.exports = {
sourceType: 'module',
project: './tsconfig.json',
},
env: {
mocha: true,
},
root: true,
};
6 changes: 0 additions & 6 deletions .mocharc.json

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore
Expand Up @@ -4,4 +4,3 @@
/test/*cache.json
/test/restDocs/*.json
/test/restDocs/results/
/test/restDocs/snapshots/
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -118,8 +118,7 @@ GAPI_MAX_PARALLEL=3 npm run lint

#### Unit (WIP)

Unit tests for this generator project are written with [Jasmine](https://jasmine.github.io/) and
[Mocha](https://mochajs.org/). They can be run via:
Unit tests for this generator project are written with [Jest](https://jestjs.io/). They can be run via:

```sh
npm run test
Expand Down
2 changes: 1 addition & 1 deletion bin/cspell.ts
Expand Up @@ -6,5 +6,5 @@ const files = (await sh.runSh('npx -y ls-ignore --paths')).stdout
.filter(x => x.trim() !== '')
.filter(x => !(x.startsWith('test/restDocs') && x.endsWith('.json')))
.filter(x => !x.startsWith('test/restDocs/results/'))
.filter(x => !x.startsWith('test/restDocs/snapshots/'));
.filter(x => !x.startsWith('test/restDocs/__snapshots__/'));
await sh.runSh(`npx -y cspell ${files.join(' ')}`);
12 changes: 12 additions & 0 deletions jest.config.ts
@@ -0,0 +1,12 @@
import {JestConfigWithTsJest} from 'ts-jest';
import {defaultsESM} from 'ts-jest/presets';

const config: JestConfigWithTsJest = {
...defaultsESM,
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
testRegex: '/test/.*(?<!\\.integration)\\.spec\\.ts$',
};

export default config;
9 changes: 9 additions & 0 deletions jest.integration.config.ts
@@ -0,0 +1,9 @@
import {JestConfigWithTsJest} from 'ts-jest';
import defaultConfig from './jest.config';

const config: JestConfigWithTsJest = {
...defaultConfig,
testRegex: '/test/.*\\.integration\\.spec\\.ts$',
};

export default config;