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

Unhelpful error message when jest is run with a preset containing a parse error #4755

Closed
niieani opened this issue Oct 24, 2017 · 2 comments · Fixed by #4766
Closed

Unhelpful error message when jest is run with a preset containing a parse error #4755

niieani opened this issue Oct 24, 2017 · 2 comments · Fixed by #4766

Comments

@niieani
Copy link
Contributor

niieani commented Oct 24, 2017

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

jest
● Validation Error:

  Preset my-custom-preset not found.

  Configuration Documentation:
  https://facebook.github.io/jest/docs/configuration.html

My preset package's JSON file (my-custom-preset) contained a trailing comma in one of the configuration, which is invalid JSON. I wasted some time trying to debug the problem.

If the current behavior is a bug, please provide the steps to reproduce

Just use an existing jest preset that contains invalid JSON.

What is the expected behavior?

Either:

  1. A helpful error message, explaining that the JSON is invalid.
  2. Parse the file as JSON5, which allows trailing commas
  3. Support for JavaScript instead of JSON preset files

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

{
  "preset": "my-custom-preset"
}
@SimenB
Copy link
Member

SimenB commented Oct 24, 2017

Point 3 is #4499

We should definitely improve the error message for json, though.

Change will be here: https://github.com/facebook/jest/blob/dd3468936c15a2dbcebe77302bc30425015d67d0/packages/jest-config/src/normalize.js#L63-L68

Should be straight forward to check what the error is

@github-actions
Copy link

This issue 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 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants