Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ matrix:
env: WEBPACK_VERSION=1 BABEL_LOADER=6
- node_js: 7
env: WEBPACK_VERSION=2 BABEL_LOADER=7
- node_js: 6
env: WEBPACK_VERSION=2 BABEL_LOADER=7
- node_js: 4
env: WEBPACK_VERSION=1 BABEL_LOADER=6
before_script:
Expand Down
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ environment:
- nodejs_version: "4"
webpack_version: "1"
babel_loader_version: "6"
- nodejs_version: "6"
webpack_version: "2"
babel_loader_version: "7"
- nodejs_version: "7"
webpack_version: "2"
babel_loader_version: "7"
Expand Down
2 changes: 1 addition & 1 deletion fixtures/config-bail/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fixture",
"name": "config-bail",
"version": "1.0.0",
"jest": {
"bail": true
Expand Down
7 changes: 7 additions & 0 deletions fixtures/config-testMatch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "config-testMatch",
"version": "1.0.0",
"jest": {
"testMatch": ["**/src/*.test2?.js"]
}
}
5 changes: 5 additions & 0 deletions fixtures/config-testMatch/src/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var fact = function(n) {
return n > 0 ? fact(n - 1) + n : 0;
};

module.exports = fact;
1 change: 1 addition & 0 deletions fixtures/config-testMatch/src/entry.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests .test', () => {});
1 change: 1 addition & 0 deletions fixtures/config-testMatch/src/entry.test2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests .test2', () => {});
14 changes: 14 additions & 0 deletions fixtures/config-testMatch/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var join = require('path').join;
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

module.exports = {
context: __dirname,
entry: './src/entry',
output: {
path: join(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new HardSourceWebpackPlugin()
]
};
2 changes: 1 addition & 1 deletion fixtures/flags-bail/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "fixture",
"name": "flags-bail",
"version": "1.0.0"
}
4 changes: 4 additions & 0 deletions fixtures/flags-testMatch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "flags-testMatch",
"version": "1.0.0"
}
5 changes: 5 additions & 0 deletions fixtures/flags-testMatch/src/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var fact = function(n) {
return n > 0 ? fact(n - 1) + n : 0;
};

module.exports = fact;
1 change: 1 addition & 0 deletions fixtures/flags-testMatch/src/entry.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests .test', () => {});
1 change: 1 addition & 0 deletions fixtures/flags-testMatch/src/entry.test2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests .test2', () => {});
14 changes: 14 additions & 0 deletions fixtures/flags-testMatch/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var join = require('path').join;
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

module.exports = {
context: __dirname,
entry: './src/entry',
output: {
path: join(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new HardSourceWebpackPlugin()
]
};
4 changes: 4 additions & 0 deletions fixtures/flags-testNamePattern/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "flags-testNamePattern",
"version": "1.0.0"
}
5 changes: 5 additions & 0 deletions fixtures/flags-testNamePattern/src/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var fact = function(n) {
return n > 0 ? fact(n - 1) + n : 0;
};

module.exports = fact;
1 change: 1 addition & 0 deletions fixtures/flags-testNamePattern/src/entry1.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests entry1', () => {});
1 change: 1 addition & 0 deletions fixtures/flags-testNamePattern/src/entry2.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests entry2', () => {});
14 changes: 14 additions & 0 deletions fixtures/flags-testNamePattern/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var join = require('path').join;
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

module.exports = {
context: __dirname,
entry: './src/entry',
output: {
path: join(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new HardSourceWebpackPlugin()
]
};
4 changes: 4 additions & 0 deletions fixtures/flags-testPathPattern/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "flags-testPathPattern",
"version": "1.0.0"
}
5 changes: 5 additions & 0 deletions fixtures/flags-testPathPattern/src/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var fact = function(n) {
return n > 0 ? fact(n - 1) + n : 0;
};

module.exports = fact;
1 change: 1 addition & 0 deletions fixtures/flags-testPathPattern/src/entry1.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests entry1', () => {});
1 change: 1 addition & 0 deletions fixtures/flags-testPathPattern/src/entry2.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests entry2', () => {});
14 changes: 14 additions & 0 deletions fixtures/flags-testPathPattern/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var join = require('path').join;
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

module.exports = {
context: __dirname,
entry: './src/entry',
output: {
path: join(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new HardSourceWebpackPlugin()
]
};
4 changes: 4 additions & 0 deletions fixtures/flags-testRegex/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "flags-testRegex",
"version": "1.0.0"
}
5 changes: 5 additions & 0 deletions fixtures/flags-testRegex/src/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var fact = function(n) {
return n > 0 ? fact(n - 1) + n : 0;
};

module.exports = fact;
1 change: 1 addition & 0 deletions fixtures/flags-testRegex/src/entry.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests .test', () => {});
1 change: 1 addition & 0 deletions fixtures/flags-testRegex/src/entry.test2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it('tests .test2', () => {});
14 changes: 14 additions & 0 deletions fixtures/flags-testRegex/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var join = require('path').join;
var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

module.exports = {
context: __dirname,
entry: './src/entry',
output: {
path: join(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new HardSourceWebpackPlugin()
]
};
2 changes: 1 addition & 1 deletion fixtures/module-multiple-loaders-test/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "fixture",
"name": "module-multiple-loaders-test",
"version": "1.0.0"
}
6 changes: 1 addition & 5 deletions fixtures/module-multiple-loaders-test/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ module.exports = {
filename: '[name].js'
},
plugins: [
new HardSourceWebpackPlugin({
// cacheDirectory: __dirname + '/node_modules/.cache/hard-source/[confighash]',
// recordsPath: __dirname + '/node_modules/.cache/hard-source/[confighash]/records.json',
// configHash: require('node-object-hash')({sort: false}).hash,
})
new HardSourceWebpackPlugin()
]
};
2 changes: 1 addition & 1 deletion fixtures/module-multiple-loaders/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "fixture",
"name": "module-multiple-loaders",
"version": "1.0.0"
}
5 changes: 1 addition & 4 deletions fixtures/module-multiple-loaders/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ module.exports = {
filename: '[name].js'
},
plugins: [
new HardSourceWebpackPlugin({
cacheDirectory: __dirname + '/node_modules/.cache/hard-source/[confighash]',
configHash: require('node-object-hash')({sort: false}).hash,
})
new HardSourceWebpackPlugin()
]
};
2 changes: 1 addition & 1 deletion fixtures/test-entries-src-babel/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "fixture",
"name": "test-entries-src-babel",
"version": "1.0.0"
}
2 changes: 1 addition & 1 deletion fixtures/test-entries-src/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "fixture",
"name": "test-entries-src",
"version": "1.0.0"
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"jest": "^20.0.4",
"node-object-hash": "^1.2.0",
"raw-loader": "^0.5.1",
"regenerator-runtime": "^0.10.5",
"rimraf": "^2.6.1",
"source-map-support": "^0.4.15",
"webpack": "^2.1.0 || ^1.13.0",
Expand All @@ -40,7 +39,13 @@
},
"dependencies": {
"find-up": "^2.1.0",
"glob": "^7.1.2",
"regenerator-runtime": "^0.10.5",
"webpack-sources": "^1.0.1"
},
"jest": {
"testPathIgnorePatterns": [
"/node_modules/",
"/fixtures/"
]
}
}
11 changes: 9 additions & 2 deletions src/common-config.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const {run, itBuilt, itSkips} = require('../fixtures/utils');
const {run, itBuilt, itSkips, itPasses, itFails} = require('../fixtures/utils');

it('bail', () => {
return run('config-bail')
.then(itBuilt(['src/entry.test.js']))
.then(itSkips(['passes']));
.then(itSkips(['passes']))
.then(itFails);
}, 30000);

it('testMatch', () => {
return run('config-testMatch')
.then(itBuilt(['src/entry.test.js', 'src/entry.test2.js']))
.then(itPasses);
}, 30000);
34 changes: 32 additions & 2 deletions src/common-flags.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
const {run, itBuilt, itSkips} = require('../fixtures/utils');
const {run, itBuilt, didNotBuild, itTests, itSkips, itPasses, itFails} =
require('../fixtures/utils');

it('--bail', () => {
return run('flags-bail', ['--bail'])
.then(itBuilt(['src/entry.test.js']))
.then(itSkips(['passes']));
.then(itSkips(['passes']))
.then(itFails);
}, 30000);

it('--testMatch', () => {
return run('flags-testMatch', ['--testMatch', '**/src/entry.test2?.js'])
.then(itBuilt(['src/entry.test.js', 'src/entry.test2.js']))
.then(itPasses);
}, 30000);

it('--testNamePattern', () => {
return run('flags-testNamePattern', ['--testNamePattern', 'entry2'])
.then(itBuilt(['src/entry1.test.js', 'src/entry2.test.js']))
.then(itTests(['entry2']))
.then(itSkips(['entry1']))
.then(itPasses);
}, 30000);

it('--testPathPattern', () => {
return run('flags-testPathPattern', ['--testPathPattern', 'entry1.test'])
.then(itBuilt(['src/entry1.test.js', 'src/entry2.test.js']))
.then(itTests(['entry1']))
.then(itSkips(['entry2']))
.then(itPasses);
}, 30000);

it('--testRegex', () => {
return run('flags-testRegex', ['--testRegex', '/entry\\.test'])
.then(itBuilt(['src/entry.test.js', 'src/entry.test2.js']))
.then(itPasses);
}, 30000);
2 changes: 1 addition & 1 deletion src/entry-reference-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class EntryReferencePlugin {
if (compilation.modules.indexOf(dep.module) === -1) {
dep.module = compilation.modules.find(module => (
module.identifier() === dep.module.identifier()
)``);
));
}
});
}
Expand Down
66 changes: 66 additions & 0 deletions src/jest-exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const {spawn} = require('child_process');
const {statSync} = require('fs');

const findUp = require('find-up');

const jestExec = (args = [], options = {}) => {
const _jestPath = findUp.sync('node_modules/.bin/jest', {
cwd: __dirname,
});
const _jestWindowsPath = _jestPath + '.cmd';

let jestPath;
try {
statSync(_jestWindowsPath);
jestPath = _jestWindowsPath;
}
catch (_) {
jestPath = _jestPath;
}

const concat = stream => {
return new Promise(resolve => {
let value = '';
stream.on('data', data => {value += data;});
stream.on('end', () => {resolve(value);});
});
};

return new Promise((resolve, reject) => {
const child = spawn(
jestPath,
args,
Object.assign({}, options, {
env: Object.assign({}, process.env, {
NODE_ENV: 'test',
}, options.env),
stdio: options.stdio || 'inherit',
})
);
let stdout, stderr;
if (options.stdio === 'pipe') {
stdout = concat(child.stdout);
stderr = concat(child.stderr);
}
child.on('exit', code => {
Promise.all([stdout, stderr])
.then(([stdout, stderr]) => {
resolve({
code,
stdout,
stderr,
});
});
});
});
};

const jestConfig = (args = [], options = {}) => {
return jestExec(args.concat('--showConfig'), {stdio: 'pipe'})
.then(({stdout}) => stdout)
.then(JSON.parse);
};

jestExec.config = jestConfig;

module.exports = jestExec;
Loading