Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass retainAllFiles from haste config #2796

Closed
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
33 changes: 33 additions & 0 deletions integration_tests/__tests__/haste-retain-all-ignore-paths-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';

const runJest = require('../runJest');
const skipOnWindows = require('skipOnWindows');

skipOnWindows.suite();

it('does not run tests in node_modules/', () => {
const result = runJest.json('haste-retain-all-ignore-paths').json;

const testNames = result.testResults.map(res => res.name).sort();

expect(
testNames.some(x => x.includes('library/__tests__/shouldnt-run.js')),
).toBe(false);
});

it('runs tests in src/node_modules/', () => {
const result = runJest.json('haste-retain-all-ignore-paths').json;

const testNames = result.testResults.map(res => res.name).sort();

expect(
testNames.some(x => x.includes('src-library/__tests__/should-run.js')),
).toBe(true);
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions integration_tests/haste-retain-all-ignore-paths/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"jest": {
"haste": {
"retainAllFiles": true
},
"testEnvironment": "node",
"testPathIgnorePatterns": [
"<rootDir>/node_modules/"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';

jest.mock('jest-haste-map', () => {
return class HeatMapMock {
constructor(options) {
this.options = options;
}
};
});

const Runtime = require('../');

const defaultHasteConfig = {
providesModuleNodeModules: [],
};

const defaultConfig = {
cacheDirectory: '',
haste: defaultHasteConfig,
mocksPattern: '',
moduleFileExtensions: [],
modulePathIgnorePatterns: [],
name: '',
testPathDirs: [],
watchman: false,
};

const defaultOptions = {
maxWorkers: 0,
resetCache: false,
};

describe('Runtime', () => {
describe('createHasteMap', () => {
it('retainAllFiles from haste config if provided', () => {
const haste = Object.assign({}, defaultHasteConfig, {
retainAllFiles: true,
});

const config = Object.assign({}, defaultConfig, {
haste,
});

const hasteMap = Runtime.createHasteMap(config, defaultOptions);

expect(hasteMap.options.retainAllFiles).toBe(true);
});

it('retainAllFiles false if not provided', () => {
const hasteMap = Runtime.createHasteMap(defaultConfig, defaultOptions);

expect(hasteMap.options.retainAllFiles).toBe(false);
});
});
});
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class Runtime {
platforms: config.haste.platforms || ['ios', 'android'],
providesModuleNodeModules: config.haste.providesModuleNodeModules,
resetCache: options && options.resetCache,
retainAllFiles: false,
retainAllFiles: config.haste.retainAllFiles || false,
roots: config.roots,
useWatchman: config.watchman,
watch: options && options.watch,
Expand Down
1 change: 1 addition & 0 deletions types/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type HasteConfig = {|
hasteImplModulePath?: string,
platforms?: Array<string>,
providesModuleNodeModules: Array<string>,
retainAllFiles?: boolean,
|};

export type ConfigGlobals = Object;
Expand Down