Skip to content

Commit

Permalink
Merge pull request #7625 from vjeux/jest15
Browse files Browse the repository at this point in the history
Update to jest 15
  • Loading branch information
cpojer authored Sep 1, 2016
2 parents 2e38fcf + 1a113a1 commit 1bd55c8
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 71 deletions.
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
Expand All @@ -107,8 +111,6 @@
"<rootDir>/src",
"node_modules/fbjs"
],
"unmockedModulePathPatterns": [
""
]
"timers": "fake"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');

Expand Down
18 changes: 0 additions & 18 deletions src/isomorphic/modern/types/__tests__/ReactFlowPropTypes-test.js

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions src/renderers/art/__tests__/ReactART-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

'use strict';

jest
.unmock('ReactART');

var React = require('React');
var ReactDOM = require('ReactDOM');
var ReactTestUtils = require('ReactTestUtils');
Expand Down
20 changes: 10 additions & 10 deletions src/renderers/dom/server/__tests__/ReactServerRendering-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,33 @@ describe('ReactServerRendering', function() {
var response = ReactServerRendering.renderToString(
<span>hello world</span>
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">hello world</span>'
);
));
});

it('should generate simple markup for self-closing tags', function() {
var response = ReactServerRendering.renderToString(
<img />
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<img ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+"/>'
);
));
});

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

it('should generate comment markup for component returns null', function() {
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('ReactServerRendering', function() {
var response = ReactServerRendering.renderToString(
<Parent />
);
expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<div ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
Expand All @@ -120,7 +120,7 @@ describe('ReactServerRendering', function() {
'<!-- react-text: [0-9]+ -->child<!-- /react-text -->' +
'</span>' +
'</div>'
);
));
});

it('should only execute certain lifecycle methods', function() {
Expand Down Expand Up @@ -172,14 +172,14 @@ describe('ReactServerRendering', function() {
<TestComponent />
);

expect(response).toMatch(
expect(response).toMatch(new RegExp(
'<span ' + ROOT_ATTRIBUTE_NAME + '="" ' +
ID_ATTRIBUTE_NAME + '="[^"]+" ' +
ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="[^"]+">' +
'<!-- react-text: [0-9]+ -->Component name: <!-- /react-text -->' +
'<!-- react-text: [0-9]+ -->TestComponent<!-- /react-text -->' +
'</span>'
);
));
expect(lifecycle).toEqual(
['getInitialState', 'componentWillMount', 'render']
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

'use strict';

jest
.unmock('EventPluginHub')
.mock('isEventSupported');
jest.mock('isEventSupported');

describe('EventPluginHub', function() {
var EventPluginHub;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/renderers/shared/utils/__tests__/accumulateInto-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

'use strict';

jest
.unmock('accumulateInto');

var accumulateInto;

describe('accumulateInto', function() {
Expand Down

0 comments on commit 1bd55c8

Please sign in to comment.