Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit e653f57

Browse files
authored
migrate tests to jest (#60)
1 parent e7e5ff8 commit e653f57

File tree

6 files changed

+2214
-734
lines changed

6 files changed

+2214
-734
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
overrides: [
77
{
88
files: ['test/**/*.js'],
9-
extends: ['@metamask/eslint-config-mocha'],
9+
extends: ['@metamask/eslint-config-jest'],
1010
},
1111
],
1212

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ package-lock.json
33

44
# Optional eslint cache
55
.eslintcache
6+
7+
# Jest
8+
/coverage

jest.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
collectCoverage: true,
3+
coverageReporters: ['text', 'html'],
4+
coverageThreshold: {
5+
global: {
6+
branches: 84,
7+
functions: 100,
8+
lines: 96,
9+
statements: 96,
10+
},
11+
},
12+
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
13+
// "resetMocks" resets all mocks, including mocked modules, to jest.fn(),
14+
// between each test case.
15+
resetMocks: true,
16+
// "restoreMocks" restores all mocks created using jest.spyOn to their
17+
// original implementations, between each test. It does not affect mocked
18+
// modules.
19+
restoreMocks: true,
20+
testEnvironment: 'node',
21+
testMatch: ['**/test/**/*.js'],
22+
testTimeout: 2500,
23+
};

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
2424
"lint": "yarn lint:eslint && yarn lint:misc --check",
2525
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
26-
"test": "mocha"
26+
"test": "jest"
2727
},
2828
"dependencies": {
2929
"@metamask/bip39": "^4.0.0",
@@ -36,15 +36,16 @@
3636
"@lavamoat/allow-scripts": "^1.0.6",
3737
"@metamask/auto-changelog": "^2.5.0",
3838
"@metamask/eslint-config": "^8.0.0",
39-
"@metamask/eslint-config-mocha": "^8.0.0",
39+
"@metamask/eslint-config-jest": "^9.0.0",
4040
"@metamask/eslint-config-nodejs": "^8.0.0",
41+
"@types/jest": "^27.4.1",
4142
"eslint": "^7.32.0",
4243
"eslint-config-prettier": "^8.3.0",
4344
"eslint-plugin-import": "^2.24.2",
44-
"eslint-plugin-mocha": "^8.1.0",
45+
"eslint-plugin-jest": "^24.3.6",
4546
"eslint-plugin-node": "^11.1.0",
4647
"eslint-plugin-prettier": "^3.3.1",
47-
"mocha": "^8.1.3",
48+
"jest": "^27.5.1",
4849
"prettier": "^2.4.1",
4950
"prettier-plugin-packagejson": "^2.2.12"
5051
},

0 commit comments

Comments
 (0)