Skip to content

Commit

Permalink
feat(scripts-jest): clear and restore mocks automatically to prevent …
Browse files Browse the repository at this point in the history
…accidental test leaks
  • Loading branch information
Hotell committed Apr 26, 2023
1 parent 49370ed commit 0c406a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 2 additions & 0 deletions scripts/jest/src/jest.preset.v0.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const createConfig = (/** @type {import('@jest/types').Config.InitialOptions} */
verbose: false,
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
testEnvironment: 'jsdom',
restoreMocks: true,
clearMocks: true,
...customConfig,
moduleNameMapper: {
...getLernaAliases({
Expand Down
9 changes: 1 addition & 8 deletions scripts/jest/src/v0/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* This is the bootstrap code that is run before any tests, utils, mocks.
*/

const enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
const enzyme = require('enzyme');

enzyme.configure({
adapter: new Adapter(),
Expand All @@ -16,11 +16,4 @@ if (process.env.TF_BUILD) {
jest.spyOn(console, 'info');
jest.spyOn(console, 'warn');
jest.spyOn(console, 'error');

afterAll(() => {
expect(console.log).not.toHaveBeenCalled();
expect(console.info).not.toHaveBeenCalled();
expect(console.warn).not.toHaveBeenCalled();
expect(console.error).not.toHaveBeenCalled();
});
}

0 comments on commit 0c406a7

Please sign in to comment.