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

[Bug]: An error occurred while adding the reporter at path "d" #12767

Closed
ext opened this issue Apr 28, 2022 · 3 comments · Fixed by #12769
Closed

[Bug]: An error occurred while adding the reporter at path "d" #12767

ext opened this issue Apr 28, 2022 · 3 comments · Fixed by #12769

Comments

@ext
Copy link

ext commented Apr 28, 2022

Version

28.0.2

Steps to reproduce

A minimal repo with the bug is available at ext/jest-28-bug-reporter-default:

  1. git clone https://github.com/ext/jest-28-bug-reporter-default.git
  2. npm install
  3. npm test

The repo contains a jest preset which sets reporters: ["default"] and in this case it references itself with "preset": ".".

Expected behavior

Running jest should succeed.

Actual behavior

Error: An error occurred while adding the reporter at path "d".
Cannot find module 'd'

This can also be seen in the logs from Github actions from the above mentioned repo.

Additional context

As a workaround modifying jest-preset.js as following works but is not the way it is documented:

 module.exports = {
-	reporters: ["default"]
+	reporters: [["default"]]
 }

It also works if I don't use a preset at all and hardcode "reporters": ["default"] directly to package.json but that would defeat the purpose of using a preset.

The real preset I have the issue with does of course add additional reporters but as the bug is reproducible without them they are left out.

Environment

System:
    OS: Linux 5.10 Gentoo Linux
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
  Binaries:
    Node: 16.14.1 - /usr/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 8.6.0 - /usr/bin/npm
  npmPackages:
    jest: ^28.0.2 => 28.0.2
@mrazauskas
Copy link
Contributor

Thanks for report and reproduction.

Looking at the code one can see that currently reporters option is normalized before merging in options from preset:

https://github.com/facebook/jest/blob/bf88f76864fe98ec45ae5035762a16e2dd03120a/packages/jest-config/src/normalize.ts#L539-L549

Hence a reporter defined in preset is not normalized, but it should be. Easy to fix. I will do.

@SimenB
Copy link
Member

SimenB commented Apr 29, 2022

https://github.com/facebook/jest/releases/tag/v28.0.3

@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 30, 2022
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.

3 participants