Skip to content

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

@niieani

Description

@niieani

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"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions