diff --git a/config/jest/environment.js b/config/jest/environment.js new file mode 100644 index 00000000000..e7c1df906c6 --- /dev/null +++ b/config/jest/environment.js @@ -0,0 +1,7 @@ +// Currently, Jest mocks setTimeout() and similar functions by default: +// https://facebook.github.io/jest/docs/timer-mocks.html +// We think this is confusing, so we disable this feature. +// If you see value in it, run `jest.useFakeTimers()` in individual tests. +beforeEach(() => { + jest.useRealTimers(); +}); diff --git a/scripts/eject.js b/scripts/eject.js index 82202d6eed9..55661d19285 100644 --- a/scripts/eject.js +++ b/scripts/eject.js @@ -41,6 +41,7 @@ prompt( path.join('config', 'webpack.config.prod.js'), path.join('config', 'jest', 'CSSStub.js'), path.join('config', 'jest', 'FileStub.js'), + path.join('config', 'jest', 'environment.js'), path.join('config', 'jest', 'transform.js'), path.join('scripts', 'build.js'), path.join('scripts', 'start.js'), diff --git a/scripts/utils/createJestConfig.js b/scripts/utils/createJestConfig.js index 282705f0dd3..d4ee867f473 100644 --- a/scripts/utils/createJestConfig.js +++ b/scripts/utils/createJestConfig.js @@ -19,7 +19,9 @@ module.exports = (resolve, rootDir) => { setupFiles: [ resolve('config/polyfills.js') ], - testEnvironment: 'node' + setupTestFrameworkScriptFile: resolve('config/jest/environment.js'), + testEnvironment: 'node', + verbose: true }; if (rootDir) { config.rootDir = rootDir;