-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The unit tests have been migrated from tape to Jest. The standard Jest config from the MetaMask module template has been used. We're using `ts-jest` to compile the tests and run them all at once, so we don't need a build step for the tests now either. The `build` command is now run separately on CI. The tape tests didn't break the tests into sections, which is commonly done for our Jest tests. So `describe` blocks haven't yet been used. I will be adding `describe` sections in later PRs though, as the tests are made more comprehensive. The tests were left mostly functionally equivalent. Some included minor changes, like checking the length of a property rather than just whether it's truthy, or checking the error message, to confirm with our Jest lint rules.
- Loading branch information
Showing
10 changed files
with
2,326 additions
and
521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,9 @@ package-lock.json | |
dist | ||
test/*.js | ||
|
||
# ESLint | ||
/.eslintcache | ||
|
||
# Jest | ||
/coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
collectCoverage: true, | ||
// Ensures that we collect coverage from all source files, not just tested | ||
// ones. | ||
collectCoverageFrom: ['./src/**.ts'], | ||
coverageReporters: ['text', 'html'], | ||
coverageThreshold: { | ||
global: { | ||
branches: 74, | ||
functions: 100, | ||
lines: 94, | ||
statements: 94, | ||
}, | ||
}, | ||
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], | ||
preset: 'ts-jest', | ||
// "resetMocks" resets all mocks, including mocked modules, to jest.fn(), | ||
// between each test case. | ||
resetMocks: true, | ||
// "restoreMocks" restores all mocks created using jest.spyOn to their | ||
// original implementations, between each test. It does not affect mocked | ||
// modules. | ||
restoreMocks: true, | ||
testEnvironment: 'node', | ||
testRegex: ['\\.test\\.(ts|js)$'], | ||
testTimeout: 2500, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.