diff --git a/package.json b/package.json index c0894ba8..0a75b8ab 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "gulp-rename": "^1.2.2", "gulp-util": "^3.0.6", "immutable": "^3.7.4", - "jest-cli": "^11.0.1", + "jest": "^15.1.1", "object-assign": "^4.0.1", "react": "^15.0.2", "react-addons-test-utils": "^15.0.1", @@ -71,18 +71,14 @@ "/lib/", "/node_modules/" ], - "persistModuleRegistryBetweenSpecs": true, "preprocessorIgnorePatterns": [ "/node_modules/" ], - "rootDir": "", + "rootDir": "./", "scriptPreprocessor": "scripts/jest/preprocessor.js", - "setupEnvScriptFile": "scripts/jest/environment.js", + "setupFiles": ["scripts/jest/environment.js"], "testPathDirs": [ "/src" - ], - "unmockedModulePathPatterns": [ - "/node_modules/(?!fbemitter)" ] } } diff --git a/scripts/jest/preprocessor.js b/scripts/jest/preprocessor.js index 8685f6c4..79d64484 100644 --- a/scripts/jest/preprocessor.js +++ b/scripts/jest/preprocessor.js @@ -1,16 +1,9 @@ var assign = require('object-assign'); var babel = require('babel-core'); -var babelDefaultOptions = require('../babel/default-options'); - -var babelOpts = babelDefaultOptions; +var babelOpts = require('../babel/default-options'); module.exports = { process: function(src, path) { - // TODO: Use preprocessorIgnorePatterns when it works. - // See https://github.com/facebook/jest/issues/385. - if (!path.match(/\/node_modules\//) && !path.match(/\/third_party\//)) { - return babel.transform(src, assign({filename: path}, babelOpts)).code; - } - return src; + return babel.transform(src, assign({filename: path}, babelOpts)).code; } }; diff --git a/src/__tests__/Dispatcher-test.js b/src/__tests__/Dispatcher-test.js index 729dc701..fb7e0dfb 100644 --- a/src/__tests__/Dispatcher-test.js +++ b/src/__tests__/Dispatcher-test.js @@ -7,9 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -jest.dontMock('Dispatcher'); -jest.dontMock('invariant'); - var Dispatcher = require('Dispatcher'); describe('Dispatcher', () => { diff --git a/src/__tests__/FluxStoreGroup-test.js b/src/__tests__/FluxStoreGroup-test.js index 36ec4017..9fb5b4a6 100644 --- a/src/__tests__/FluxStoreGroup-test.js +++ b/src/__tests__/FluxStoreGroup-test.js @@ -10,11 +10,6 @@ * @typechecks */ -jest - .dontMock('Dispatcher') - .dontMock('FluxStore') - .dontMock('FluxStoreGroup'); - var Dispatcher = require('Dispatcher'); var FluxStore = require('FluxStore'); var FluxStoreGroup = require('FluxStoreGroup'); diff --git a/src/stores/__tests__/FluxReduceStore-test.js b/src/stores/__tests__/FluxReduceStore-test.js index 38cf3651..44a06812 100644 --- a/src/stores/__tests__/FluxReduceStore-test.js +++ b/src/stores/__tests__/FluxReduceStore-test.js @@ -9,11 +9,6 @@ * @emails oncall+uiecommd */ -jest - .dontMock('Dispatcher') - .dontMock('FluxReduceStore') - .dontMock('FluxStore'); - var Dispatcher = require('Dispatcher'); var FluxReduceStore = require('FluxReduceStore'); var Immutable = require('immutable'); @@ -48,6 +43,7 @@ describe('FluxReduceStore', () => { var dispatcher = new Dispatcher(); store = new FooStore(dispatcher); dispatch = dispatcher.dispatch.bind(dispatcher); + store.__emitter.emit = jest.fn(); onChange = store.__emitter.emit; }); diff --git a/src/stores/__tests__/FluxStore-test.js b/src/stores/__tests__/FluxStore-test.js index 74afee05..faf6f597 100644 --- a/src/stores/__tests__/FluxStore-test.js +++ b/src/stores/__tests__/FluxStore-test.js @@ -10,9 +10,8 @@ * @typechecks */ -jest - .dontMock('FluxStore') - .dontMock('invariant'); // This shouldn't be necessary. Not sure why it is. +jest.mock('fbemitter'); +jest.mock('Dispatcher'); var FluxStore = require('FluxStore'); var Dispatcher = require('Dispatcher');