Skip to content

Conversation

@nickserv
Copy link
Contributor

@nickserv nickserv commented Sep 14, 2021

What: Use modulePaths to improve Jest 27 imports

Why: Fixes #219 which would unblock testing-library/eslint-plugin-jest-dom#185

How:

  • Moved all moduleDirectories (except node_modules) to modulePaths, which properly prioritizes resolving node_modules over local project modules
    • It's theoretically possible that this could break a test that relies on the opposite functionality, though IMO that would not be a good assumption to make, and it's worth noting that semver does not protect users from breaking changes resulting from bug fixes
  • Switched to using <rootDir>, which should provide better support for kcd-scripts test in monorepos
  • Ran an end to end test using npm link within testing-library/eslint-plugin-jest-dom
    • The entire test suite now passes with Jest 26 (previously passing) and 27 (previously failing)

Checklist:

  • Documentation N/A
  • Tests
  • Ready to be merged

@nickserv nickserv changed the title fix: use modulePaths instead of moduleDirectories fix: use modulePaths instead of moduleDirectories Sep 14, 2021
@nickserv nickserv changed the title fix: use modulePaths instead of moduleDirectories fix: use modulePaths instead of moduleDirectories to improve Jest 27 imports Sep 14, 2021
@nickserv nickserv changed the title fix: use modulePaths instead of moduleDirectories to improve Jest 27 imports fix: use modulePaths to improve Jest 27 imports Sep 14, 2021
Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Cool 👍 Thanks!

@codecov
Copy link

codecov bot commented Sep 15, 2021

Codecov Report

Merging #220 (99ba287) into main (32f3cfb) will not change coverage.
The diff coverage is 50.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #220   +/-   ##
=======================================
  Coverage   63.29%   63.29%           
=======================================
  Files          21       21           
  Lines         594      594           
  Branches      222      222           
=======================================
  Hits          376      376           
  Misses        177      177           
  Partials       41       41           
Impacted Files Coverage Δ
src/config/jest.config.js 92.30% <50.00%> (ø)

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 32f3cfb...99ba287. Read the comment docs.

@kentcdodds kentcdodds merged commit 438ed61 into kentcdodds:main Sep 15, 2021
@github-actions
Copy link

🎉 This PR is included in version 11.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nickserv nickserv deleted the use-module-paths branch September 15, 2021 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ESLint cannot be imported in Jest 27

4 participants