question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature]: Lift `moduleFileExtensions` option validation.

See original GitHub issue

🚀 Feature Proposal

Do not validate that moduleFileExtensions must include "js". We could change it to not empty or even allow empty array values to result in not finding any test files. Perhaps with a warning, example below.

Motivation

As we are moving towards supporting ESM #9430, users writing test entirely as esModules (or transpiled/formed to) would find it confusing that they must include a "js" extension.

Example

// jest.config.mjs
export default {
  moduleFileExtensions: [
    "mjs",
  ],
  testRegex: "test\.mjs",
  transform: {},
};

As of v27.4.0 will get this error

● Validation Error:

  moduleFileExtensions must include 'js':
  but instead received:
    ["mjs"]
  Please change your configuration to include 'js'.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

The script failed with exit code 1

Pitch

Well, this is clearly a jest validation rule.

The existing no tests found message

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in /path/to/root/test/dir.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: https://jestjs.io/docs/configuration
Pattern:  - 0 matches
The script failed with exit code 1

Particularly, the line

Make sure Jest's configuration does not exclude this directory.

Could be extened to

Make sure Jest's configuration does not exclude this directory and extension of test files.

Or perhaps

Make sure Jest's configuration includes this directory and extension of test files.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ahnpnlcommented, Dec 4, 2021

I know what you want to say, it’s just my opinion. It’s not like I don’t get what you meant:)

0reactions
demskingcommented, May 9, 2022

How to mock fs/promises with ESM?

Read more comments on GitHub >

github_iconTop Results From Across the Web

jest-validate | Yarn - Package Manager
Generic configuration validation tool that helps you with warnings, errors and deprecation messages as well as showing users examples of correct configuration.
Read more >
babel ignores - make sure to include the file in jest's ... - You.com
Feature Proposal. Do not validate that moduleFileExtensions must include "js" . We could change it to not empty or even allow empty array...
Read more >
Configuring Jest
The bail config option can be used here to have Jest stop running tests after ... It must be a node module that...
Read more >
LinkedIn Brand Lift Testing Management API - Microsoft Learn
Caller provides this field as -1 when trying to validate the ... The choice of lift test entity determines which campaigns to operate...
Read more >
Configuring package.json · Jest
When using the --config option, the JSON file must not contain a "jest" key: ... moduleFileExtensions [array<string>]; moduleDirectories [array<string>] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found