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

Treat setupFilesAfterEnv like setupFiles when normalizing configs against presets #9495

Merged
merged 2 commits into from
Feb 2, 2020

Conversation

staylor
Copy link
Contributor

@staylor staylor commented Feb 2, 2020

The value of setupFiles from a local Jest config is concatenated to the value of setupFiles from a preset when the local Jest config specifies preset and setupFiles. The same should be true for setupFilesAfterEnv. Without this change, if the local Jest config wants to take advantage of the setupFilesAfterEnv files from the preset, it has to redeclare them:

// jest-preset-foo
module.exports = {
  setupFilesAfterEnv: ['a'],
};

// local jest.config.js
module.exports = {
  preset: 'jest-preset-foo',
  setupFilesAfterEnv: ['b'],
};

Before:
Value of setupFilesAfterEnv = ['b']

After:
Value of setupFilesAfterEnv = ['a', 'b']

@codecov-io
Copy link

Codecov Report

Merging #9495 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9495      +/-   ##
==========================================
+ Coverage      65%   65.02%   +0.02%     
==========================================
  Files         283      283              
  Lines       12131    12133       +2     
  Branches     3002     3004       +2     
==========================================
+ Hits         7886     7890       +4     
+ Misses       3604     3603       -1     
+ Partials      641      640       -1
Impacted Files Coverage Δ
packages/jest-config/src/normalize.ts 77.87% <100%> (+0.12%) ⬆️
packages/expect/src/utils.ts 96.22% <0%> (+1.25%) ⬆️

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 b9a7787...e3cef0a. Read the comment docs.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Good catch, thanks! Mind updating the changelog as well?

Copy link
Contributor

@jeysal jeysal left a comment

Choose a reason for hiding this comment

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

LGTM, just missing a changelog entry (of type fix) as Simen said. Thanks!

@staylor
Copy link
Contributor Author

staylor commented Feb 2, 2020

added entry to changelog, thanks!

@SimenB SimenB merged commit fdd700f into jestjs:master Feb 2, 2020
@SimenB
Copy link
Member

SimenB commented Feb 2, 2020

Thank you!

@danielbayley
Copy link

danielbayley commented Apr 2, 2020

@staylor @SimenB @jeysal But what if I want the local setupFilesAfterEnv to override the preset? This broke my jest-preset-coffeescript package, as I was relying on this previous behaviour… How can I do that now?

@wrslatz
Copy link
Contributor

wrslatz commented Apr 16, 2020

Same issue as @danielbayley ... we're working in a nx monorepo. We rely on having different setupFilesAfterEnv in root jest.config.js and in each app / lib in our monorepo.

The root config with a specific setupFilesAfterEnv is so that IDEs that only respect a single jest.config.js in the root of the project can run the jest tests across the entire monorepo. The underlying configs for each app / lib are customized to those projects but extend from the root jest.config.js to use some common config. An example where IDE support is now broken is with https://github.com/jest-community/vscode-jest.

See nrwl/nx#2344 (comment) and nrwl/nx#2314 (comment) for further details

@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 11, 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.

7 participants