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

Remove mocksPattern, rename testPathDirs to roots. #2776

Merged
merged 3 commits into from
Feb 7, 2017

Conversation

cpojer
Copy link
Member

@cpojer cpojer commented Feb 1, 2017

Summary
As mentioned in #2600.

  • Adding mocksPattern was a poor decision on my part. We used to have "testsPattern" but I didn't realize then that we actually hardcoded some paths for mocks, so it never worked. I'm removing it with no replacement to pay down this technical debt.
  • People mis-use testPathDirs to limit the tests they are using but it shouldn't be used for that, renaming it to roots.

Test plan
jest


There are times where you only want Jest to search in a single sub-directory (such as cases where you have a `src/` directory in your repo), but prevent it from accessing the rest of the repo.

*Note: While `rootDir` is mostly used as a token to be re-used in other configuration options, `roots` is used by the internals of Jest to locate test files and source files. By default, `roots` has a single entry `<rootDir>` but there are cases where you want to have multiple roots within one project, for example `roots: ["<rootDir>/src/", "<rootDir>/tests/"]`.*
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd bold this phrase: "locate test files and source files"

}

Please update your configuration.
`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also mention deprecating mocksPattern

Copy link
Member Author

Choose a reason for hiding this comment

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

Nobody can use it because it is broken, so I'd rather just kill it directly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

😄

@@ -11,11 +11,11 @@

const path = require('path');

const mocksPattern = '__mocks__';
const MOCKS_PATTERN = path.sep + '__mocks__' + path.sep;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we could hoist MOCKS_PATTERN it to jest-util? It appears in 2 packages and 3 different places.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want jest-haste-map to depend on jest-util.

@ColCh
Copy link
Contributor

ColCh commented Feb 1, 2017

@cpojer I've removed mocksPattern in this PR #2705 *

comment: #2705 (comment)

  • forgot to update the title, sorry. updated just now

@cpojer cpojer force-pushed the master branch 2 times, most recently from d9b69cd to e44cbee Compare February 2, 2017 19:44
@cpojer
Copy link
Member Author

cpojer commented Feb 7, 2017

finally managed to find some time to fix things here.

@codecov-io
Copy link

codecov-io commented Feb 7, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@085c136). Click here to learn what that means.

@@            Coverage Diff            @@
##             master    #2776   +/-   ##
=========================================
  Coverage          ?   67.65%           
=========================================
  Files             ?      140           
  Lines             ?     5076           
  Branches          ?        0           
=========================================
  Hits              ?     3434           
  Misses            ?     1642           
  Partials          ?        0
Impacted Files Coverage Δ
packages/jest-config/src/validConfig.js 100% <ø> (ø)
packages/jest-config/src/defaults.js 100% <ø> (ø)
packages/jest-runtime/src/index.js 85.95% <ø> (ø)
packages/jest-runtime/src/transform.js 87.87% <ø> (ø)
packages/jest-config/src/deprecated.js 85.71% <ø> (ø)
packages/jest-haste-map/src/getMockName.js 100% <100%> (ø)
...s/jest-editor-support/src/parsers/BabylonParser.js 98.93% <100%> (ø)
packages/jest-runtime/src/shouldInstrument.js 68.18% <100%> (ø)
packages/jest-config/src/normalize.js 85.51% <50%> (ø)
packages/jest-cli/src/SearchSource.js 61.62% <66.66%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 085c136...3cc443a. Read the comment docs.

@cpojer cpojer merged commit 5d9a08e into jestjs:master Feb 7, 2017
mthmulders added a commit to mthmulders/stryker-jest-runner that referenced this pull request Feb 10, 2017
This in preparation of future Jest versions (> 18.1) that
will have `testPathDirs` renamed to `roots`.
See jestjs/jest#2776.
nicojs pushed a commit to stryker-mutator/stryker-jest-runner that referenced this pull request Feb 10, 2017
* chore: remove some template files from the plugin-seed
* chore: update project files for newer Stryker version
* chore(doc): Show correct Travis badge
* test(all): Add sample project for running integration tests
* fix(build) Explicitly list jest-runtime as dep
* fix(TestRunner): Add testPathDirs option
Add `testPathDirs` option to the jest test runner options in order to make it work on the windows platform. I'm not jet sure that `process.cwd()` is the correct value, but it seems to work for now.
* chore(build) Do not attempt to run on Node < 6.0.0
* fix(runner) Also specify `roots` option
This in preparation of future Jest versions (> 18.1) that
will have `testPathDirs` renamed to `roots`.
See jestjs/jest#2776.
skovhus pushed a commit to skovhus/jest that referenced this pull request Apr 29, 2017
* Remove mocksPattern config.

* Rename `testPathDirs` to `roots`.

* Fix mocks pattern.
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* Remove mocksPattern config.

* Rename `testPathDirs` to `roots`.

* Fix mocks pattern.
sanderkoenders pushed a commit to stryker-mutator/stryker-js that referenced this pull request Jul 6, 2018
* chore: remove some template files from the plugin-seed
* chore: update project files for newer Stryker version
* chore(doc): Show correct Travis badge
* test(all): Add sample project for running integration tests
* fix(build) Explicitly list jest-runtime as dep
* fix(TestRunner): Add testPathDirs option
Add `testPathDirs` option to the jest test runner options in order to make it work on the windows platform. I'm not jet sure that `process.cwd()` is the correct value, but it seems to work for now.
* chore(build) Do not attempt to run on Node < 6.0.0
* fix(runner) Also specify `roots` option
This in preparation of future Jest versions (> 18.1) that
will have `testPathDirs` renamed to `roots`.
See jestjs/jest#2776.
sanderkoenders pushed a commit to stryker-mutator/stryker-js that referenced this pull request Jul 6, 2018
The roots and testPathDirs attributes of the configuration passed to Jest may both be left undefined.

This has the added advantage of continuing to work once testPathDirs has been deprecated in Jest 19.0.0.  See jestjs/jest#2776
nicojs pushed a commit to stryker-mutator/stryker-js that referenced this pull request Jul 8, 2018
* chore: remove some template files from the plugin-seed
* chore: update project files for newer Stryker version
* chore(doc): Show correct Travis badge
* test(all): Add sample project for running integration tests
* fix(build) Explicitly list jest-runtime as dep
* fix(TestRunner): Add testPathDirs option
Add `testPathDirs` option to the jest test runner options in order to make it work on the windows platform. I'm not jet sure that `process.cwd()` is the correct value, but it seems to work for now.
* chore(build) Do not attempt to run on Node < 6.0.0
* fix(runner) Also specify `roots` option
This in preparation of future Jest versions (> 18.1) that
will have `testPathDirs` renamed to `roots`.
See jestjs/jest#2776.
nicojs pushed a commit to stryker-mutator/stryker-js that referenced this pull request Jul 8, 2018
The roots and testPathDirs attributes of the configuration passed to Jest may both be left undefined.

This has the added advantage of continuing to work once testPathDirs has been deprecated in Jest 19.0.0.  See jestjs/jest#2776
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants