Skip to content

Commit 72442a1

Browse files
committed
Merge branch 'jest'
2 parents 2dea671 + 1911918 commit 72442a1

File tree

14 files changed

+891
-444
lines changed

14 files changed

+891
-444
lines changed

bin/react-scripts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const args = process.argv.slice(3);
88
switch (script) {
99
case 'build':
1010
case 'start':
11-
case 'test':
12-
case 'test:watch':
11+
case 'test': {
1312
const result = spawn.sync(
1413
'node',
1514
[require.resolve(path.join('../scripts', script))].concat(args),
1615
{ stdio: 'inherit' }
1716
);
1817
process.exit(result.status);
1918
break;
19+
}
2020
default:
2121
console.log(`Unknown script "${script}".`);
2222
break;

config/webpack.test.js

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

lib/graphqlProxyMiddleware.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ const httpProxy = require('http-proxy');
99
const proxy = httpProxy.createProxyServer();
1010

1111
module.exports = (graphqlOrigin) => (req, res) => {
12-
console.log(req.body);
13-
1412
proxy.web(req, res, { target: graphqlOrigin }, err => {
15-
console.error(err);
16-
// don't crash plz
13+
console.error(err); // this prevents crash
1714
});
1815
};

lib/mockRelay.js

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

lib/testSetup.js

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

package.json

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-scripts",
3-
"version": "0.12.0",
3+
"version": "0.13.0",
44
"description": "shared react site configs",
55
"main": "index.js",
66
"author": "First Look Media",
@@ -12,6 +12,7 @@
1212
"autoprefixer": "^6.3.7",
1313
"babel": "^6.5.2",
1414
"babel-core": "^6.11.4",
15+
"babel-jest": "^19.0.0",
1516
"babel-loader": "^6.2.4",
1617
"babel-plugin-transform-runtime": "^6.12.0",
1718
"babel-polyfill": "^6.9.1",
@@ -24,20 +25,21 @@
2425
"concat-stream": "^1.5.2",
2526
"cross-spawn": "^4.0.0",
2627
"css-loader": "^0.23.1",
28+
"enzyme-to-json": "^1.5.1",
2729
"express": "^4.14.0",
2830
"extract-text-webpack-plugin": "^1.0.1",
2931
"file-loader": "^0.9.0",
3032
"filesize": "^3.3.0",
3133
"fs-extra": "^2.0.0",
3234
"gzip-size": "^3.0.0",
3335
"http-proxy": "^1.14.0",
36+
"identity-obj-proxy": "^3.0.0",
3437
"image-webpack-loader": "^2.0.0",
3538
"imports-loader": "^0.6.5",
39+
"jest": "^19.0.2",
3640
"jsdom": "^9.4.1",
3741
"json-loader": "^0.5.4",
3842
"loader-utils": "^0.2.16",
39-
"mocha": "^2.5.3",
40-
"mocha-webpack": "^0.5.0",
4143
"postcss-calc": "^5.3.1",
4244
"postcss-loader": "^0.9.1",
4345
"precss": "^1.4.0",
@@ -52,32 +54,24 @@
5254
"webpack-node-externals": "^1.3.3"
5355
},
5456
"peerDependencies": {
55-
"babel-runtime": "^6.11.6",
56-
"chai": "^3.5.0",
57-
"chai-enzyme": "^0.5.0",
58-
"enzyme": "^2.4.1",
59-
"react": "^15.3.0",
60-
"react-addons-test-utils": "^15.3.0",
61-
"react-dom": "^15.3.0",
62-
"react-relay": "^0.9.0",
63-
"sinon": "^1.17.5",
64-
"sinon-chai": "^2.8.0",
65-
"source-map-support": "^0.4.2"
57+
"babel-runtime": ">=6.11.6",
58+
"enzyme": ">=2.7.1",
59+
"react": ">=15.3.0",
60+
"react-addons-test-utils": ">=15.3.0",
61+
"react-dom": ">=15.3.0",
62+
"react-relay": ">=0.9.0",
63+
"source-map-support": ">=0.4.2"
6664
},
6765
"devDependencies": {
68-
"babel-relay-plugin": "^0.9.3",
69-
"chai": "^3.5.0",
70-
"chai-enzyme": "^0.5.2",
66+
"babel-relay-plugin": ">=0.9.3",
7167
"core-js": "^2.4.1",
72-
"enzyme": "^2.5.1",
68+
"enzyme": "^2.7.1",
7369
"eslint": "^3.2.2",
7470
"eslint-config-airbnb-base": "^5.0.1",
7571
"eslint-plugin-import": "^1.12.0",
7672
"react": "^15.3.2",
7773
"react-addons-test-utils": "^15.3.2",
7874
"react-dom": "^15.3.2",
79-
"sinon": "^1.17.6",
80-
"sinon-chai": "^2.8.0",
8175
"source-map-support": "^0.4.6"
8276
}
8377
}

scripts/test.js

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
const spawn = require('cross-spawn');
2-
const path = require('path');
1+
const jest = require('jest');
2+
3+
const argv = process.argv.slice(2);
34

4-
const testConfig = path.resolve(__dirname, '../config/webpack.test.js');
5-
const mochaWebpack = path.resolve(__dirname, '../node_modules/.bin/mocha-webpack');
6-
const setup = path.resolve(__dirname, '../lib/testSetup.js');
5+
// Watch unless on CI or in coverage mode
6+
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
7+
argv.push('--watch');
8+
}
79

8-
console.log('Running tests...');
10+
const createJestConfig = require('./utils/createJestConfig');
11+
const path = require('path');
912

10-
const child = spawn(
11-
'node',
12-
[
13-
mochaWebpack,
14-
'--colors',
15-
'--exit',
16-
'--webpack-config', testConfig,
17-
'--require', setup,
18-
'src/**/__spec.js',
19-
],
20-
{ stdio: 'inherit' }
13+
argv.push(
14+
'--config',
15+
JSON.stringify(createJestConfig())
2116
);
2217

23-
child.on('close', code => process.exit(code));
24-
child.on('exit', code => process.exit(code));
25-
child.on('disconnect', code => process.exit(1));
18+
jest.run(argv);

scripts/test:watch.js

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

scripts/utils/__mocks__/file.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'test-file-stub';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const Relay = require('react-relay');
2+
3+
module.exports = {
4+
QL: Relay.QL,
5+
Mutation: Relay.Mutation,
6+
Route: Relay.Route,
7+
RootContainer: () => null,
8+
createContainer: (component) => component,
9+
};

0 commit comments

Comments
 (0)