@samitouri / QOS-React / commits / 1a113a15c9

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.

Christopher Chedeau committed Aug 31, 2016 at 13:33 UTC 1a113a15c9395aee85b6c9dd2a84c0137fab59bb
11 files changed +28 -71
package.json
+10 -8
@@ -58,7 +58,7 @@
58 "gulp-load-plugins": "^1.2.4",
59 "gulp-util": "^3.0.7",
60 "gzip-js": "~0.3.2",
61 - "jest": "^12.1.1",
61 + "jest": "^15.0.1",
62 "loose-envify": "^1.1.0",
63 "merge-stream": "^1.0.0",
64 "object-assign": "^4.1.0",
@@ -90,14 +90,18 @@
90 "/.module-cache/",
91 "/react/build/"
92 ],
93 - "persistModuleRegistryBetweenSpecs": true,
93 "rootDir": "",
94 "scriptPreprocessor": "scripts/jest/preprocessor.js",
96 - "setupEnvScriptFile": "scripts/jest/environment.js",
95 + "setupFiles": [
96 + "scripts/jest/environment.js"
97 + ],
98 "setupTestFrameworkScriptFile": "scripts/jest/test-framework-setup.js",
98 - "testFileExtensions": [
99 - "coffee",
99 + "testRegex": "/__tests__/",
100 + "moduleFileExtensions": [
101 "js",
102 + "json",
103 + "node",
104 + "coffee",
105 "ts"
106 ],
107 "testPathDirs": [
@@ -107,8 +111,6 @@
111 "<rootDir>/src",
112 "node_modules/fbjs"
113 ],
110 - "unmockedModulePathPatterns": [
111 - ""
112 - ]
114 + "timers": "fake"
115 }
116 }
scripts/jest/setupSpecEquivalenceReporter.js renamed
src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js
+6 -2
@@ -32,7 +32,11 @@ describe('ReactClassEquivalence', function() {
32 function runJest(testFile) {
33 var cwd = process.cwd();
34 var jestBin = path.resolve('node_modules', '.bin', 'jest');
35 - var setupFile = path.resolve(__dirname, 'setupSpecEquivalenceReporter.js');
35 + var setupFile = path.resolve(
36 + 'scripts',
37 + 'jest',
38 + 'setupSpecEquivalenceReporter.js'
39 + );
40 var result = spawnSync('node', [
41 jestBin,
42 testFile,
@@ -60,7 +64,7 @@ function runJest(testFile) {
64 }
65
66 function compareResults(a, b) {
63 - var regexp = /^EQUIVALENCE.*$/gm;
67 + var regexp = /EQUIVALENCE.*$/gm;
68 var aSpecs = (a.match(regexp) || []).sort().join('\n');
69 var bSpecs = (b.match(regexp) || []).sort().join('\n');
70
src/isomorphic/modern/types/__tests__/ReactFlowPropTypes-test.js deleted
-18
@@ -1,18 +0,0 @@
1 -/**
2 - * Copyright 2014-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @emails react-core
10 - */
11 -
12 -'use strict';
13 -
14 -describe('ReactFlowPropTypes', function() {
15 -
16 - // TODO: Test Flow integration and ensure that prop types works.
17 -
18 -});
src/isomorphic/modern/types/__tests__/ReactTypeScriptPropTypes-test.js deleted
-18
@@ -1,18 +0,0 @@
1 -/**
2 - * Copyright 2014-present, Facebook, Inc.
3 - * All rights reserved.
4 - *
5 - * This source code is licensed under the BSD-style license found in the
6 - * LICENSE file in the root directory of this source tree. An additional grant
7 - * of patent rights can be found in the PATENTS file in the same directory.
8 - *
9 - * @emails react-core
10 - */
11 -
12 -'use strict';
13 -
14 -describe('ReactTypeScriptPropTypes', function() {
15 -
16 - // TODO: Test TypeScript integration and ensure that prop types works.
17 -
18 -});
src/renderers/art/__tests__/ReactART-test.js
-3
@@ -13,9 +13,6 @@
13
14 'use strict';
15
16 -jest
17 - .unmock('ReactART');
18 -
16 var React = require('React');
17 var ReactDOM = require('ReactDOM');
18 var ReactTestUtils = require('ReactTestUtils');
src/renderers/dom/server/__tests__/ReactServerRendering-test.js
+10 -10
@@ -45,33 +45,33 @@ describe('ReactServerRendering', function() {
45 var response = ReactServerRendering.renderToString(
46 <span>hello world</span>
47 );
48 - expect(response).toMatch(
48 + expect(response).toMatch(new RegExp(
49 '<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
50 ID_ATTRIBUTE_NAME + '="[^"]+" ' +
51 ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">hello world</span>'
52 - );
52 + ));
53 });
54
55 it('should generate simple markup for self-closing tags', function() {
56 var response = ReactServerRendering.renderToString(
57 <img />
58 );
59 - expect(response).toMatch(
59 + expect(response).toMatch(new RegExp(
60 '<img ' + ROOT_ATTRIBUTE_NAME + '="" ' +
61 ID_ATTRIBUTE_NAME + '="[^"]+" ' +
62 ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+"/>'
63 - );
63 + ));
64 });
65
66 it('should generate simple markup for attribute with `>` symbol', function() {
67 var response = ReactServerRendering.renderToString(
68 <img data-attr=">" />
69 );
70 - expect(response).toMatch(
70 + expect(response).toMatch(new RegExp(
71 '<img data-attr="&gt;" ' + ROOT_ATTRIBUTE_NAME + '="" ' +
72 ID_ATTRIBUTE_NAME + '="[^"]+" ' +
73 ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+"/>'
74 - );
74 + ));
75 });
76
77 it('should generate comment markup for component returns null', function() {
@@ -111,7 +111,7 @@ describe('ReactServerRendering', function() {
111 var response = ReactServerRendering.renderToString(
112 <Parent />
113 );
114 - expect(response).toMatch(
114 + expect(response).toMatch(new RegExp(
115 '<div ' + ROOT_ATTRIBUTE_NAME + '="" ' +
116 ID_ATTRIBUTE_NAME + '="[^"]+" ' +
117 ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
@@ -120,7 +120,7 @@ describe('ReactServerRendering', function() {
120 '<!-- react-text: [0-9]+ -->child<!-- /react-text -->' +
121 '</span>' +
122 '</div>'
123 - );
123 + ));
124 });
125
126 it('should only execute certain lifecycle methods', function() {
@@ -172,14 +172,14 @@ describe('ReactServerRendering', function() {
172 <TestComponent />
173 );
174
175 - expect(response).toMatch(
175 + expect(response).toMatch(new RegExp(
176 '<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
177 ID_ATTRIBUTE_NAME + '="[^"]+" ' +
178 ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
179 '<!-- react-text: [0-9]+ -->Component name: <!-- /react-text -->' +
180 '<!-- react-text: [0-9]+ -->TestComponent<!-- /react-text -->' +
181 '</span>'
182 - );
182 + ));
183 expect(lifecycle).toEqual(
184 ['getInitialState', 'componentWillMount', 'render']
185 );
src/renderers/native/__tests__/ReactNativeAttributePayload-test.js
-5
@@ -9,11 +9,6 @@
9 */
10 'use strict';
11
12 -jest.unmock('ReactNativeAttributePayload');
13 -jest.unmock('ReactNativePropRegistry');
14 -// jest.dontMock('deepDiffer');
15 -// jest.dontMock('flattenStyle');
16 -
12 var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
13 var ReactNativePropRegistry = require('ReactNativePropRegistry');
14
src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js
+1 -3
@@ -11,9 +11,7 @@
11
12 'use strict';
13
14 -jest
15 - .unmock('EventPluginHub')
16 - .mock('isEventSupported');
14 +jest.mock('isEventSupported');
15
16 describe('EventPluginHub', function() {
17 var EventPluginHub;
src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js
+1 -1
@@ -60,7 +60,7 @@ var expectChildren = function(d, children) {
60 openingCommentNode = outerNode.childNodes[mountIndex];
61
62 expect(openingCommentNode.nodeType).toBe(8);
63 - expect(openingCommentNode.nodeValue).toMatch(' react-text: [0-9]+ ');
63 + expect(openingCommentNode.nodeValue).toMatch(/ react-text: [0-9]+ /);
64
65 if (child === '') {
66 textNode = null;
src/renderers/shared/utils/__tests__/accumulateInto-test.js
-3
@@ -11,9 +11,6 @@
11
12 'use strict';
13
14 -jest
15 - .unmock('accumulateInto');
16 -
14 var accumulateInto;
15
16 describe('accumulateInto', function() {