Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1bd55c8

Browse files
authored
Merge pull request react#7625 from vjeux/jest15
Update to jest 15
2 parents 2e38fcf + 1a113a1 commit 1bd55c8

11 files changed

Lines changed: 28 additions & 71 deletions

File tree

package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"gulp-load-plugins": "^1.2.4",
5959
"gulp-util": "^3.0.7",
6060
"gzip-js": "~0.3.2",
61-
"jest": "^12.1.1",
61+
"jest": "^15.0.1",
6262
"loose-envify": "^1.1.0",
6363
"merge-stream": "^1.0.0",
6464
"object-assign": "^4.1.0",
@@ -90,14 +90,18 @@
9090
"/.module-cache/",
9191
"/react/build/"
9292
],
93-
"persistModuleRegistryBetweenSpecs": true,
9493
"rootDir": "",
9594
"scriptPreprocessor": "scripts/jest/preprocessor.js",
96-
"setupEnvScriptFile": "scripts/jest/environment.js",
95+
"setupFiles": [
96+
"scripts/jest/environment.js"
97+
],
9798
"setupTestFrameworkScriptFile": "scripts/jest/test-framework-setup.js",
98-
"testFileExtensions": [
99-
"coffee",
99+
"testRegex": "/__tests__/",
100+
"moduleFileExtensions": [
100101
"js",
102+
"json",
103+
"node",
104+
"coffee",
101105
"ts"
102106
],
103107
"testPathDirs": [
@@ -107,8 +111,6 @@
107111
"<rootDir>/src",
108112
"node_modules/fbjs"
109113
],
110-
"unmockedModulePathPatterns": [
111-
""
112-
]
114+
"timers": "fake"
113115
}
114116
}

src/isomorphic/modern/class/__tests__/setupSpecEquivalenceReporter.js renamed to scripts/jest/setupSpecEquivalenceReporter.js

File renamed without changes.

src/isomorphic/modern/class/__tests__/ReactClassEquivalence-test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ describe('ReactClassEquivalence', function() {
3232
function runJest(testFile) {
3333
var cwd = process.cwd();
3434
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+
);
3640
var result = spawnSync('node', [
3741
jestBin,
3842
testFile,
@@ -60,7 +64,7 @@ function runJest(testFile) {
6064
}
6165

6266
function compareResults(a, b) {
63-
var regexp = /^EQUIVALENCE.*$/gm;
67+
var regexp = /EQUIVALENCE.*$/gm;
6468
var aSpecs = (a.match(regexp) || []).sort().join('\n');
6569
var bSpecs = (b.match(regexp) || []).sort().join('\n');
6670

src/isomorphic/modern/types/__tests__/ReactFlowPropTypes-test.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/isomorphic/modern/types/__tests__/ReactTypeScriptPropTypes-test.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/renderers/art/__tests__/ReactART-test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
'use strict';
1515

16-
jest
17-
.unmock('ReactART');
18-
1916
var React = require('React');
2017
var ReactDOM = require('ReactDOM');
2118
var ReactTestUtils = require('ReactTestUtils');

src/renderers/dom/server/__tests__/ReactServerRendering-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,33 @@ describe('ReactServerRendering', function() {
4545
var response = ReactServerRendering.renderToString(
4646
<span>hello world</span>
4747
);
48-
expect(response).toMatch(
48+
expect(response).toMatch(new RegExp(
4949
'<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
5050
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
5151
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">hello world</span>'
52-
);
52+
));
5353
});
5454

5555
it('should generate simple markup for self-closing tags', function() {
5656
var response = ReactServerRendering.renderToString(
5757
<img />
5858
);
59-
expect(response).toMatch(
59+
expect(response).toMatch(new RegExp(
6060
'<img ' + ROOT_ATTRIBUTE_NAME + '="" ' +
6161
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
6262
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+"/>'
63-
);
63+
));
6464
});
6565

6666
it('should generate simple markup for attribute with `>` symbol', function() {
6767
var response = ReactServerRendering.renderToString(
6868
<img data-attr=">" />
6969
);
70-
expect(response).toMatch(
70+
expect(response).toMatch(new RegExp(
7171
'<img data-attr="&gt;" ' + ROOT_ATTRIBUTE_NAME + '="" ' +
7272
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
7373
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+"/>'
74-
);
74+
));
7575
});
7676

7777
it('should generate comment markup for component returns null', function() {
@@ -111,7 +111,7 @@ describe('ReactServerRendering', function() {
111111
var response = ReactServerRendering.renderToString(
112112
<Parent />
113113
);
114-
expect(response).toMatch(
114+
expect(response).toMatch(new RegExp(
115115
'<div ' + ROOT_ATTRIBUTE_NAME + '="" ' +
116116
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
117117
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
@@ -120,7 +120,7 @@ describe('ReactServerRendering', function() {
120120
'<!-- react-text: [0-9]+ -->child<!-- /react-text -->' +
121121
'</span>' +
122122
'</div>'
123-
);
123+
));
124124
});
125125

126126
it('should only execute certain lifecycle methods', function() {
@@ -172,14 +172,14 @@ describe('ReactServerRendering', function() {
172172
<TestComponent />
173173
);
174174

175-
expect(response).toMatch(
175+
expect(response).toMatch(new RegExp(
176176
'<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
177177
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
178178
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
179179
'<!-- react-text: [0-9]+ -->Component name: <!-- /react-text -->' +
180180
'<!-- react-text: [0-9]+ -->TestComponent<!-- /react-text -->' +
181181
'</span>'
182-
);
182+
));
183183
expect(lifecycle).toEqual(
184184
['getInitialState', 'componentWillMount', 'render']
185185
);

src/renderers/native/__tests__/ReactNativeAttributePayload-test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
*/
1010
'use strict';
1111

12-
jest.unmock('ReactNativeAttributePayload');
13-
jest.unmock('ReactNativePropRegistry');
14-
// jest.dontMock('deepDiffer');
15-
// jest.dontMock('flattenStyle');
16-
1712
var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
1813
var ReactNativePropRegistry = require('ReactNativePropRegistry');
1914

src/renderers/shared/stack/event/__tests__/EventPluginHub-test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
'use strict';
1313

14-
jest
15-
.unmock('EventPluginHub')
16-
.mock('isEventSupported');
14+
jest.mock('isEventSupported');
1715

1816
describe('EventPluginHub', function() {
1917
var EventPluginHub;

src/renderers/shared/stack/reconciler/__tests__/ReactMultiChildText-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var expectChildren = function(d, children) {
6060
openingCommentNode = outerNode.childNodes[mountIndex];
6161

6262
expect(openingCommentNode.nodeType).toBe(8);
63-
expect(openingCommentNode.nodeValue).toMatch(' react-text: [0-9]+ ');
63+
expect(openingCommentNode.nodeValue).toMatch(/ react-text: [0-9]+ /);
6464

6565
if (child === '') {
6666
textNode = null;

0 commit comments

Comments
 (0)