diff --git a/package.json b/package.json index 40f7e832ec868..af4ef20252911 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "gulp-load-plugins": "^1.2.4", "gulp-util": "^3.0.7", "gzip-js": "~0.3.2", - "jest": "^12.1.1", + "jest": "^15.0.1", "loose-envify": "^1.1.0", "merge-stream": "^1.0.0", "object-assign": "^4.1.0", @@ -90,14 +90,18 @@ "/.module-cache/", "/react/build/" ], - "persistModuleRegistryBetweenSpecs": true, "rootDir": "", "scriptPreprocessor": "scripts/jest/preprocessor.js", - "setupEnvScriptFile": "scripts/jest/environment.js", + "setupFiles": [ + "scripts/jest/environment.js" + ], "setupTestFrameworkScriptFile": "scripts/jest/test-framework-setup.js", - "testFileExtensions": [ - "coffee", + "testRegex": "/__tests__/", + "moduleFileExtensions": [ "js", + "json", + "node", + "coffee", "ts" ], "testPathDirs": [ @@ -107,8 +111,6 @@ "/src", "node_modules/fbjs" ], - "unmockedModulePathPatterns": [ - "" - ] + "timers": "fake" } } diff --git a/src/isomorphic/modern/class/__tests__/setupSpecEquivalenceReporter.js b/scripts/jest/setupSpecEquivalenceReporter.js similarity index 100% rename from src/isomorphic/modern/class/__tests__/setupSpecEquivalenceReporter.js rename to scripts/jest/setupSpecEquivalenceReporter.js diff --git a/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js b/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js index 0d91c3a144f7d..79f669adbeb18 100644 --- a/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js +++ b/src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js @@ -32,7 +32,11 @@ describe('ReactClassEquivalence', function() { function runJest(testFile) { var cwd = process.cwd(); var jestBin = path.resolve('node_modules', '.bin', 'jest'); - var setupFile = path.resolve(__dirname, 'setupSpecEquivalenceReporter.js'); + var setupFile = path.resolve( + 'scripts', + 'jest', + 'setupSpecEquivalenceReporter.js' + ); var result = spawnSync('node', [ jestBin, testFile, @@ -60,7 +64,7 @@ function runJest(testFile) { } function compareResults(a, b) { - var regexp = /^EQUIVALENCE.*$/gm; + var regexp = /EQUIVALENCE.*$/gm; var aSpecs = (a.match(regexp) || []).sort().join('\n'); var bSpecs = (b.match(regexp) || []).sort().join('\n'); diff --git a/src/isomorphic/modern/types/__tests__/ReactFlowPropTypes-test.js b/src/isomorphic/modern/types/__tests__/ReactFlowPropTypes-test.js deleted file mode 100644 index 986b918780ec0..0000000000000 --- a/src/isomorphic/modern/types/__tests__/ReactFlowPropTypes-test.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright 2014-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @emails react-core - */ - -'use strict'; - -describe('ReactFlowPropTypes', function() { - - // TODO: Test Flow integration and ensure that prop types works. - -}); diff --git a/src/isomorphic/modern/types/__tests__/ReactTypeScriptPropTypes-test.js b/src/isomorphic/modern/types/__tests__/ReactTypeScriptPropTypes-test.js deleted file mode 100644 index 82a72b42849e5..0000000000000 --- a/src/isomorphic/modern/types/__tests__/ReactTypeScriptPropTypes-test.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright 2014-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @emails react-core - */ - -'use strict'; - -describe('ReactTypeScriptPropTypes', function() { - - // TODO: Test TypeScript integration and ensure that prop types works. - -}); diff --git a/src/renderers/art/__tests__/ReactART-test.js b/src/renderers/art/__tests__/ReactART-test.js index 173bd3453fafa..459f808d45f8a 100644 --- a/src/renderers/art/__tests__/ReactART-test.js +++ b/src/renderers/art/__tests__/ReactART-test.js @@ -13,9 +13,6 @@ 'use strict'; -jest - .unmock('ReactART'); - var React = require('React'); var ReactDOM = require('ReactDOM'); var ReactTestUtils = require('ReactTestUtils'); diff --git a/src/renderers/dom/server/__tests__/ReactServerRendering-test.js b/src/renderers/dom/server/__tests__/ReactServerRendering-test.js index 1c3753028a3e6..075947a6f4e18 100644 --- a/src/renderers/dom/server/__tests__/ReactServerRendering-test.js +++ b/src/renderers/dom/server/__tests__/ReactServerRendering-test.js @@ -45,33 +45,33 @@ describe('ReactServerRendering', function() { var response = ReactServerRendering.renderToString( hello world ); - expect(response).toMatch( + expect(response).toMatch(new RegExp( 'hello world' - ); + )); }); it('should generate simple markup for self-closing tags', function() { var response = ReactServerRendering.renderToString( ); - expect(response).toMatch( + expect(response).toMatch(new RegExp( '' - ); + )); }); it('should generate simple markup for attribute with `>` symbol', function() { var response = ReactServerRendering.renderToString( ); - expect(response).toMatch( + expect(response).toMatch(new RegExp( '' - ); + )); }); it('should generate comment markup for component returns null', function() { @@ -111,7 +111,7 @@ describe('ReactServerRendering', function() { var response = ReactServerRendering.renderToString( ); - expect(response).toMatch( + expect(response).toMatch(new RegExp( '
' + @@ -120,7 +120,7 @@ describe('ReactServerRendering', function() { 'child' + '' + '
' - ); + )); }); it('should only execute certain lifecycle methods', function() { @@ -172,14 +172,14 @@ describe('ReactServerRendering', function() { ); - expect(response).toMatch( + expect(response).toMatch(new RegExp( '' + 'Component name: ' + 'TestComponent' + '' - ); + )); expect(lifecycle).toEqual( ['getInitialState', 'componentWillMount', 'render'] ); diff --git a/src/renderers/native/__tests__/ReactNativeAttributePayload-test.js b/src/renderers/native/__tests__/ReactNativeAttributePayload-test.js index 85d4283d13928..d85396394b36b 100644 --- a/src/renderers/native/__tests__/ReactNativeAttributePayload-test.js +++ b/src/renderers/native/__tests__/ReactNativeAttributePayload-test.js @@ -9,11 +9,6 @@ */ 'use strict'; -jest.unmock('ReactNativeAttributePayload'); -jest.unmock('ReactNativePropRegistry'); -// jest.dontMock('deepDiffer'); -// jest.dontMock('flattenStyle'); - var ReactNativeAttributePayload = require('ReactNativeAttributePayload'); var ReactNativePropRegistry = require('ReactNativePropRegistry'); diff --git a/src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js b/src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js index 9583bccf97949..2062704c9ca99 100644 --- a/src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js +++ b/src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js @@ -11,9 +11,7 @@ 'use strict'; -jest - .unmock('EventPluginHub') - .mock('isEventSupported'); +jest.mock('isEventSupported'); describe('EventPluginHub', function() { var EventPluginHub; diff --git a/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js b/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js index 9983644894deb..864a390aeb24b 100644 --- a/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js +++ b/src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js @@ -60,7 +60,7 @@ var expectChildren = function(d, children) { openingCommentNode = outerNode.childNodes[mountIndex]; expect(openingCommentNode.nodeType).toBe(8); - expect(openingCommentNode.nodeValue).toMatch(' react-text: [0-9]+ '); + expect(openingCommentNode.nodeValue).toMatch(/ react-text: [0-9]+ /); if (child === '') { textNode = null; diff --git a/src/renderers/shared/utils/__tests__/accumulateInto-test.js b/src/renderers/shared/utils/__tests__/accumulateInto-test.js index a9b5d7130a984..aa26aee128132 100644 --- a/src/renderers/shared/utils/__tests__/accumulateInto-test.js +++ b/src/renderers/shared/utils/__tests__/accumulateInto-test.js @@ -11,9 +11,6 @@ 'use strict'; -jest - .unmock('accumulateInto'); - var accumulateInto; describe('accumulateInto', function() {