Skip to content

Commit

Permalink
Tweak Jest default settings (facebook#378)
Browse files Browse the repository at this point in the history
Disable timer mocking and enable verbose output.
  • Loading branch information
gaearon authored and feiqitian committed Oct 25, 2016
1 parent 3fe65ee commit ecacd55
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config/jest/environment.js
Original file line number Diff line number Diff line change
@@ -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();
});
1 change: 1 addition & 0 deletions scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
4 changes: 3 additions & 1 deletion scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ecacd55

Please sign in to comment.