Skip to content

Commit

Permalink
Move assignment of cwd to default config (#7146)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte authored Oct 12, 2018
1 parent a1f3e2c commit fbd66d3
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 17 deletions.
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(
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

0 comments on commit fbd66d3

Please sign in to comment.