Skip to content

Commit

Permalink
glob projects
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Jul 26, 2017
1 parent d3c4d23 commit 0e16326
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 16 additions & 0 deletions integration_tests/__tests__/multi_project_runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ test('resolves projects and their <rootDir> properly', () => {
expect(stderr).toMatch(' PASS project1/__tests__/test.test.js');
expect(stderr).toMatch(' PASS project2/__tests__/test.test.js');

// Use globs
writeFiles(DIR, {
'dir1/random_file': '',
'dir2/random_file': '',
'package.json': JSON.stringify({
jest: {
projects: ['**/*.conf.json'],
},
}),
});

({stderr} = runJest(DIR));
expect(stderr).toMatch('Ran all test suites in 2 projects.');
expect(stderr).toMatch(' PASS project1/__tests__/test.test.js');
expect(stderr).toMatch(' PASS project2/__tests__/test.test.js');

// Include two projects that will resolve to the same config
writeFiles(DIR, {
'dir1/random_file': '',
Expand Down
10 changes: 9 additions & 1 deletion packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {Argv} from 'types/Argv';
import type {InitialOptions, ReporterConfig} from 'types/Config';

import crypto from 'crypto';
import glob from 'glob';
import path from 'path';
import {ValidationError, validate} from 'jest-validate';
import validatePattern from './validate_pattern';
Expand Down Expand Up @@ -428,7 +429,14 @@ function normalize(options: InitialOptions, argv: Argv) {
break;
case 'projects':
value = (options[key] || [])
.map(project => _replaceRootDirTags(options.rootDir, project));
.map(project => _replaceRootDirTags(options.rootDir, project))
.reduce((projects, project) => {
// Project can be specified as globs. If a glob matches any files,
// We expand it to these paths. If not, we keep the original path
// for the future resolution.
const globMatches = glob.sync(project);
return projects.concat(globMatches.length ? globMatches : project);
}, []);
break;
case 'moduleDirectories':
case 'testMatch':
Expand Down

0 comments on commit 0e16326

Please sign in to comment.