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

Move assignment of cwd to default config #7146

Merged
merged 1 commit into from
Oct 12, 2018
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- `[jest-jasmine2]` Pending calls inside async tests are reported as pending not failed ([#6782](https://github.com/facebook/jest/pull/6782))
- `[jest-circus]` Better error message when a describe block is empty ([#6372](https://github.com/facebook/jest/pull/6372))
- `[jest-cli]` Fix unhandled error when a bad revision is provided to `changedSince` ([#7115](https://github.com/facebook/jest/pull/7115))
- `[jest-config]` Moved dynamically assigned `cwd` from `jest-cli` to default configuration in `jest-config` ([#7146](https://github.com/facebook/jest/pull/7146))

### Chore & Maintenance

Expand Down
1 change: 1 addition & 0 deletions e2e/__tests__/__snapshots__/show_config.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
\\"coveragePathIgnorePatterns\\": [
\\"/node_modules/\\"
],
\\"cwd\\": \\"<<REPLACED_ROOT_DIR>>\\",
\\"detectLeaks\\": false,
\\"detectOpenHandles\\": false,
\\"errorOnDeprecated\\": false,
Expand Down
17 changes: 0 additions & 17 deletions packages/jest-cli/src/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ import FailedTestsCache from './FailedTestsCache';
import {JestHook} from 'jest-watcher';
import collectNodeHandles from './collectHandles';

const setConfig = (contexts, newConfig) =>
contexts.forEach(
context =>
(context.config = Object.freeze(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't wanna freeze anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already frozen in jest-config. We only freeze it here because we're creating a new instance, which isn't necessary anymore.

Object.assign({}, context.config, newConfig),
)),
);

const getTestPaths = async (
globalConfig,
context,
Expand Down Expand Up @@ -256,15 +248,6 @@ export default (async function runJest({
globalConfig = Object.freeze(newConfig);
}

// When using more than one context, make all printed paths relative to the
// current cwd. Do not modify rootDir, since will be used by custom resolvers.
// If --runInBand is true, the resolver saved a copy during initialization,
// however, if it is running on spawned processes, the initiation of the
// custom resolvers is done within each spawned process and it needs the
// original value of rootDir. Instead, use the {cwd: Path} property to resolve
// paths when printing.
setConfig(contexts, {cwd: process.cwd()});

let collectHandles;

if (globalConfig.detectOpenHandles) {
Expand Down
1 change: 1 addition & 0 deletions packages/jest-config/src/Defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default ({
coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
coverageReporters: ['json', 'text', 'lcov', 'clover'],
coverageThreshold: null,
cwd: process.cwd(),
detectLeaks: false,
detectOpenHandles: false,
errorOnDeprecated: false,
Expand Down
1 change: 1 addition & 0 deletions types/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type DefaultOptions = {|
coveragePathIgnorePatterns: Array<string>,
coverageReporters: Array<string>,
coverageThreshold: ?{global: {[key: string]: number}},
cwd: Path,
errorOnDeprecated: boolean,
expand: boolean,
filter: ?Path,
Expand Down