Skip to content

Commit

Permalink
Add projects option, rename initial config to options.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Apr 28, 2017
1 parent 53bea61 commit d9c1c03
Show file tree
Hide file tree
Showing 12 changed files with 1,280 additions and 208 deletions.
10 changes: 5 additions & 5 deletions packages/jest-cli/src/cli/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ const options = {
description: 'Use this flag to show full diffs instead of a patch.',
type: 'boolean',
},
experimentalProjects: {
description: 'A list of projects that use Jest to run all tests in a ' +
'single run.',
type: 'array',
},
findRelatedTests: {
description: 'Find related tests for a list of source files that were ' +
'passed in as arguments. Useful for pre-commit hook integration to run ' +
Expand Down Expand Up @@ -181,6 +176,11 @@ const options = {
'also specified.',
type: 'string',
},
projects: {
description: 'A list of projects that use Jest to run all tests of all ' +
'projects in a single instance of Jest.',
type: 'array',
},
runInBand: {
alias: 'i',
description: 'Run all tests serially in the current process (rather than ' +
Expand Down
1 change: 0 additions & 1 deletion packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function run(argv?: Object, root?: Path) {
root = pkgDir.sync();
}

argv.projects = argv.experimentalProjects;
if (!argv.projects) {
argv.projects = [root];
}
Expand Down
34 changes: 29 additions & 5 deletions packages/jest-cli/src/cli/runCLI.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,43 @@ module.exports = async (
};

try {
const configs = await Promise.all(
roots.map(root => readConfig(argv, root)),
);
let globalConfig;
let hasDeprecationWarnings;
let configs = [];
let config;
if (roots.length === 1) {
({config, globalConfig, hasDeprecationWarnings} = await readConfig(
argv,
roots[0],
));
configs = [{config, globalConfig, hasDeprecationWarnings}];
if (globalConfig.projects && globalConfig.projects.length) {
roots = globalConfig.projects;
}
}

if (roots.length > 1) {
configs = await Promise.all(roots.map(root => readConfig(argv, root)));
// If no config was passed initially, use the one from the first project
if (!globalConfig && !config) {
globalConfig = configs[0].globalConfig;
config = configs[0].config;
}
}

if (!config || !globalConfig || !configs.length) {
throw new Error('jest: No configuration found for any project.');
}

if (argv.debug || argv.showConfig) {
logDebugMessages(configs[0].globalConfig, configs[0].config, pipe);
logDebugMessages(globalConfig, config, pipe);
}

if (argv.showConfig) {
process.exit(0);
}

await _run(configs[0].globalConfig, configs);
await _run(globalConfig, configs);
} catch (error) {
clearLine(process.stderr);
clearLine(process.stdout);
Expand Down
1 change: 1 addition & 0 deletions packages/jest-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"main": "build/index.js",
"dependencies": {
"chalk": "^1.1.3",
"glob": "^7.1.1",
"jest-environment-jsdom": "^19.0.2",
"jest-environment-node": "^19.0.2",
"jest-jasmine2": "^19.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports[`preset throws when preset not found 1`] = `
</>"
`;
exports[`rootDir throws if the config is missing a rootDir property 1`] = `
exports[`rootDir throws if the options is missing a rootDir property 1`] = `
"<red><bold><bold>● <bold>Validation Error:
Configuration option <bold>rootDir must be specified.
Expand Down
Loading

0 comments on commit d9c1c03

Please sign in to comment.