Skip to content

Commit

Permalink
Fixes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
pugnascotia committed Jan 23, 2017
1 parent 6975bdd commit 1b0f158
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
.eslintcache
*.swp
*~
.idea
*.iml
/examples/*/node_modules/
/integration_tests/*/node_modules
/integration_tests/transform/*/coverage
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/__tests__/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test('config as JSON', () => {
const result = runJest('verbose_reporter', [
'--config=' + JSON.stringify({
testEnvironment: 'node',
testRegex: 'banana strawbery kiwi',
testGlob: ['banana strawbery kiwi'],
}),
]);
const stdout = result.stdout.toString();
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-cli/src/SearchSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {HasteContext} from 'types/HasteMap';
import type {Glob, Path} from 'types/Config';
import type {ResolveModuleConfig} from 'jest-resolve';

const mm = require('micromatch');
const micromatch = require('micromatch');

const DependencyResolver = require('jest-resolve-dependencies');

Expand Down Expand Up @@ -78,13 +78,13 @@ const globsToMatcher = (globs: ?Array<Glob>) => {
return () => true;
}

const matchers = globs.map(each => mm.matcher(each));
const matchers = globs.map(each => micromatch.matcher(each));

return (path: Path) => matchers.some(each => each(path));
};

const regexToMatcher = (testRegex: string) => {
if (!testRegex.length) {
if (!testRegex) {
return () => true;
}

Expand Down
10 changes: 5 additions & 5 deletions packages/jest-cli/src/__tests__/SearchSource-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('SearchSource', () => {
config = normalizeConfig({
name,
rootDir: '.',
testGlob: [],
testGlob: null,
testPathDirs: [],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$',
});
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('SearchSource', () => {
moduleFileExtensions: ['js', 'jsx', 'txt'],
name,
rootDir,
testGlob: [],
testGlob: null,
testRegex: 'not-really-a-test',
});
return findMatchingTests(config).then(data => {
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('SearchSource', () => {
moduleFileExtensions: ['js', 'jsx'],
name,
rootDir,
testGlob: [],
testGlob: null,
testRegex: 'test\.jsx?',
});
return findMatchingTests(config).then(data => {
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('SearchSource', () => {
const config = normalizeConfig({
name,
rootDir,
testGlob: [],
testGlob: null,
testRegex,
});
return findMatchingTests(config).then(data => {
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('SearchSource', () => {
const config = normalizeConfig({
name,
rootDir,
testGlob: [],
testGlob: null,
testRegex,
});
return findMatchingTests(config).then(data => {
Expand Down
11 changes: 4 additions & 7 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@ function normalize(config: InitialConfig, argv: Object = {}) {
case 'unmockedModulePathPatterns':
value = normalizeUnmockedModulePathPatterns(config, key);
break;

case 'testRegex':
value = config[key];
break;

case 'automock':
case 'bail':
case 'browser':
Expand Down Expand Up @@ -352,6 +347,7 @@ function normalize(config: InitialConfig, argv: Object = {}) {
case 'rootDir':
case 'testGlob':
case 'testEnvironment':
case 'testRegex':
case 'testReporter':
case 'testRunner':
case 'testURL':
Expand All @@ -376,8 +372,9 @@ function normalize(config: InitialConfig, argv: Object = {}) {
}
}

if (config.testRegex && (!config.testGlob || config.testGlob.length === 0)) {
// Prevent default glob conflicting with any explicit `testRegex` value
if (config.testRegex && (!config.testGlob)) {
// Prevent the default testGlob conflicting with any explicitly
// configured `testRegex` value
newConfig.testGlob = [];
}

Expand Down
2 changes: 0 additions & 2 deletions packages/jest-editor-support/src/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const {jestChildProcessWithArgs} = require('./Process');
type Glob = string;

type ConfigRepresentation = {
testRegex: string,
testGlob: Array<Glob>
}

Expand All @@ -51,7 +50,6 @@ module.exports = class Settings extends EventEmitter {
'**/__tests__/**/*.js?(x)',
'**/?(*.)(spec|test).js?(x)',
],
testRegex: '(/__tests__/.*|\\.(test|spec))\\.jsx?$',
};
}

Expand Down
6 changes: 4 additions & 2 deletions packages/jest-runtime/src/shouldInstrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ const shouldInstrument = (filename: Path, config: Config): boolean => {
return false;
}

if (config.testGlob && config.testGlob.length
&& micromatch.any(filename, config.testGlob)) {
if (
config.testGlob &&
config.testGlob.length &&
micromatch.any(filename, config.testGlob)) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/jest-util/src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {Config, Glob, Path} from 'types/Config';
import type {AssertionResult, TestResult} from 'types/TestResult';

const chalk = require('chalk');
const mm = require('micromatch');
const micromatch = require('micromatch');
const path = require('path');
const separateMessageFromStack = require('./separateMessageFromStack');

Expand Down Expand Up @@ -121,7 +121,7 @@ const formatPaths = (
// highlight paths from the current test file
if (
(config.testGlob && config.testGlob.length
&& mm(filePath, config.testGlob)) ||
&& micromatch(filePath, config.testGlob)) ||
filePath === relativeTestPath
) {
filePath = chalk.reset.cyan(filePath);
Expand Down

0 comments on commit 1b0f158

Please sign in to comment.