From 1a113a15c9395aee85b6c9dd2a84c0137fab59bb Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 31 Aug 2016 13:33:25 -0700 Subject: [PATCH] Update to jest 15 Jest 15 has just been released and is way more awesome: http://facebook.github.io/jest/blog/2016/09/01/jest-15.html This pull request updates jest from version 12 to 15. Right now there's a fix in jest around Symbol that hasn't been released yet, so this will break CI and cannot be merged it. But once it ships by the end of the day, we'll be good to go :) See comments inline for all the changes I've done. --- package.json | 18 +++++++++-------- .../jest}/setupSpecEquivalenceReporter.js | 0 .../__tests__/ReactClassEquivalence-test.js | 8 ++++++-- .../__tests__/ReactFlowPropTypes-test.js | 18 ----------------- .../ReactTypeScriptPropTypes-test.js | 18 ----------------- src/renderers/art/__tests__/ReactART-test.js | 3 --- .../__tests__/ReactServerRendering-test.js | 20 +++++++++---------- .../ReactNativeAttributePayload-test.js | 5 ----- .../event/__tests__/EventPluginHub-test.js | 4 +--- .../__tests__/ReactMultiChildText-test.js | 2 +- .../utils/__tests__/accumulateInto-test.js | 3 --- 11 files changed, 28 insertions(+), 71 deletions(-) rename {src/isomorphic/modern/class/__tests__ => scripts/jest}/setupSpecEquivalenceReporter.js (100%) delete mode 100644 src/isomorphic/modern/types/__tests__/ReactFlowPropTypes-test.js delete mode 100644 src/isomorphic/modern/types/__tests__/ReactTypeScriptPropTypes-test.js 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() {