Skip to content

Commit 8084a32

Browse files
authored
Tweak Jest default settings (#378)
Disable timer mocking and enable verbose output.
1 parent 6fb517a commit 8084a32

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

config/jest/environment.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Currently, Jest mocks setTimeout() and similar functions by default:
2+
// https://facebook.github.io/jest/docs/timer-mocks.html
3+
// We think this is confusing, so we disable this feature.
4+
// If you see value in it, run `jest.useFakeTimers()` in individual tests.
5+
beforeEach(() => {
6+
jest.useRealTimers();
7+
});

scripts/eject.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ prompt(
4141
path.join('config', 'webpack.config.prod.js'),
4242
path.join('config', 'jest', 'CSSStub.js'),
4343
path.join('config', 'jest', 'FileStub.js'),
44+
path.join('config', 'jest', 'environment.js'),
4445
path.join('config', 'jest', 'transform.js'),
4546
path.join('scripts', 'build.js'),
4647
path.join('scripts', 'start.js'),

scripts/utils/createJestConfig.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ module.exports = (resolve, rootDir) => {
1919
setupFiles: [
2020
resolve('config/polyfills.js')
2121
],
22-
testEnvironment: 'node'
22+
setupTestFrameworkScriptFile: resolve('config/jest/environment.js'),
23+
testEnvironment: 'node',
24+
verbose: true
2325
};
2426
if (rootDir) {
2527
config.rootDir = rootDir;

0 commit comments

Comments
 (0)