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

feat: add support for .mjs config #9431

Merged
merged 9 commits into from Jan 21, 2020
Merged

feat: add support for .mjs config #9431

merged 9 commits into from Jan 21, 2020

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Jan 19, 2020

Summary

This fixes #9225. It is a breaking change since readConfig and readConfigs now return promises. The error isn't too good on older versions of node, but I think that's fine.

image

Test plan

Tests added, although they only run on node 13

* LICENSE file in the root directory of this source tree.
*/

export const PACKAGE_JSON = 'package.json';
Copy link
Member Author

Choose a reason for hiding this comment

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

this was essentially a duplicate of the file in jest-config, so I just exported it from there and deleted this

@SimenB SimenB mentioned this pull request Jan 19, 2020
21 tasks
@@ -298,33 +299,37 @@ export function readConfigs(
? projects[0] === realpath(process.cwd())
: projects[0] === process.cwd();

const parsedConfigs = projects
Copy link
Member Author

Choose a reason for hiding this comment

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

ignore whitespace - I just wrapped the old array in await Promise.all


configObject = importedConfig.default;
} catch (error) {
if (error.message === 'Not supported') {
Copy link
Member Author

Choose a reason for hiding this comment

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

afaik there's no clean way of detecting support for import function before trying to use it. I think this is fine, though

@@ -73,26 +73,26 @@ export function run(cliArgv?: Config.Argv, cliInfo?: Array<string>) {
// Break circular dependency
const Runtime: any = require('..');

(Runtime.createContext(config, {
Copy link
Member Author

Choose a reason for hiding this comment

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

ignore whitespace, I just unwrapped .then().catch() to async-await

@codecov-io
Copy link

codecov-io commented Jan 20, 2020

Codecov Report

Merging #9431 into master will decrease coverage by 0.09%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #9431     +/-   ##
=========================================
- Coverage   65.06%   64.97%   -0.1%     
=========================================
  Files         283      283             
  Lines       12088    12099     +11     
  Branches     2983     2989      +6     
=========================================
- Hits         7865     7861      -4     
- Misses       3588     3602     +14     
- Partials      635      636      +1
Impacted Files Coverage Δ
packages/jest-config/src/importMjs.ts 0% <0%> (ø)
...ges/jest-config/src/readConfigFileAndSetRootDir.ts 0% <0%> (ø) ⬆️
packages/jest-config/src/index.ts 11.59% <0%> (-0.18%) ⬇️
packages/jest-config/src/constants.ts 100% <100%> (ø) ⬆️
packages/jest-cli/src/init/index.ts 82.6% <100%> (+0.79%) ⬆️
packages/jest-cli/src/init/generate_config_file.ts 96% <66.66%> (-4%) ⬇️
packages/expect/src/utils.ts 94.96% <0%> (-1.26%) ⬇️

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 8236779...115d211. Read the comment docs.

@SimenB
Copy link
Member Author

SimenB commented Jan 21, 2020

Need to land so it goes into 25. It's a new feature, so if there's something broken here it won't break anyone

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

support jest.config.mjs and jest.config.cjs
3 participants