Skip to content

Commit

Permalink
Address code review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
chenesan committed Apr 26, 2020
1 parent 0d50802 commit 913617b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
3 changes: 1 addition & 2 deletions packages/jest-core/src/SearchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ export default class SearchSource {
const dependencyResolver = this._getOrBuildDependencyResolver();
const relatedSourcesSet = new Set<string>();
changedFiles.forEach(filePath => {
const isTestFile = this.isTestFilePath(filePath);
if (isTestFile) {
if (this.isTestFilePath(filePath)) {
const sourcePaths = dependencyResolver.resolve(filePath, {
skipNodeResolution: this._context.config.skipNodeResolution,
});
Expand Down
13 changes: 6 additions & 7 deletions packages/jest-core/src/__tests__/SearchSource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ describe('SearchSource', () => {
'../../../jest-runtime/src/__tests__/test_root',
);

beforeEach(done => {
beforeEach(async () => {
const {options: config} = normalize(
{
haste: {
Expand All @@ -553,12 +553,11 @@ describe('SearchSource', () => {
},
{} as Config.Argv,
);
Runtime.createContext(config, {maxWorkers, watchman: false}).then(
context => {
searchSource = new SearchSource(context);
done();
},
);
const context = await Runtime.createContext(config, {
maxWorkers,
watchman: false,
});
searchSource = new SearchSource(context);
});

it('return empty set if no SCM', () => {
Expand Down
14 changes: 6 additions & 8 deletions packages/jest-transform/src/shouldInstrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,12 @@ export default function shouldInstrument(
return false;
}

if (options.changedFiles) {
if (!options.changedFiles.has(filename)) {
if (!options.sourcesRelatedToTestsInChangedFiles) {
return false;
}
if (!options.sourcesRelatedToTestsInChangedFiles.has(filename)) {
return false;
}
if (options.changedFiles && !options.changedFiles.has(filename)) {
if (!options.sourcesRelatedToTestsInChangedFiles) {
return false;
}
if (!options.sourcesRelatedToTestsInChangedFiles.has(filename)) {
return false;
}
}

Expand Down

0 comments on commit 913617b

Please sign in to comment.