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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom reporters option eats all following arguments up to the next option #10257

Closed
dobesv opened this issue Jul 8, 2020 · 4 comments
Closed

Comments

@dobesv
Copy link

dobesv commented Jul 8, 2020

#10191 馃悰 Bug Report

When using the --reporters option, it takes its argument and all following arguments up to the next option to be custom reports.

This differs from the documentation which suggests that you should repeat --reporters once for each reporter.

To Reproduce

$ yarn jest --reporters=default xyz
Error: Could not resolve a module for a custom reporter.
  Module name: xyz
    at /home/ubuntu/app/node_modules/jest-config/build/normalize.js:557:15
    at Array.map (<anonymous>)
    at normalizeReporters (/home/ubuntu/app/node_modules/jest-config/build/normalize.js:539:33)
    at normalize (/home/ubuntu/app/node_modules/jest-config/build/normalize.js:632:5)
    at readConfig (/home/ubuntu/app/node_modules/jest-config/build/index.js:224:68)
    at async readConfigs (/home/ubuntu/app/node_modules/jest-config/build/index.js:404:26)
    at async runCLI (/home/ubuntu/app/node_modules/@jest/core/build/cli/index.js:230:59)
    at async Object.run (/home/ubuntu/app/node_modules/jest-cli/build/cli/index.js:163:37)
$ yarn jest --reporters=default --runInBand xyz
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /home/ubuntu/app
  16908 files checked across 3 projects. Run with `--verbose` for more details.
Pattern: xyz - 0 matches
$ yarn jest --reporters=default xyz --runInBand xyz
Error: Could not resolve a module for a custom reporter.
  Module name: xyz
    at /home/ubuntu/app/node_modules/jest-config/build/normalize.js:557:15
    at Array.map (<anonymous>)
    at normalizeReporters (/home/ubuntu/app/node_modules/jest-config/build/normalize.js:539:33)
    at normalize (/home/ubuntu/app/node_modules/jest-config/build/normalize.js:632:5)
    at readConfig (/home/ubuntu/app/node_modules/jest-config/build/index.js:224:68)
    at async readConfigs (/home/ubuntu/app/node_modules/jest-config/build/index.js:404:26)
    at async runCLI (/home/ubuntu/app/node_modules/@jest/core/build/cli/index.js:230:59)
    at async Object.run (/home/ubuntu/app/node_modules/jest-cli/build/cli/index.js:163:37)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

If I use --reporters=xxx yyy or --reporters xxx yyy it should only add xxx as a reporter and leave yyy as a leftover argument to jest.

envinfo

  System:
    OS: Linux 5.4 Linux Mint 19.3 (Tricia)
    CPU: (6) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.19.0 - /usr/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
  npmPackages:
    jest: 26.1.0 => 26.1.0 

Workaround

Ensure that --reporters has an option between it and any non-option command line arguments.

@scinos
Copy link
Contributor

scinos commented May 13, 2021

This is still happening with Jest 26.6.3

  System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.12 - ~/.nvm/versions/node/v14.16.1/bin/npm
  npmPackages:
    jest: ^26.4.0 => 26.6.3

Another workaround is use --:

yarn jest --reporters=default -- xyz

Edit: no, that doesn't actually work. Jest doesn't complain anymore but the reporter is not used.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@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 Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants