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] the --outputFile parameter is not working when --junit parameter is issued #443

Closed
squidjam opened this issue Mar 20, 2024 · 4 comments
Labels
question Further information is requested

Comments

@squidjam
Copy link

squidjam commented Mar 20, 2024

Describe the bug
When you issue the --junit parameter to generate a junitXML test report, the --outputFile parameter doesn't allow you to set the name of the output report file (but it does on --json), and a file with a default name (junit.xml) is generated.

To Reproduce
Steps to reproduce the behavior:

  1. Run yarn test-storybook --junit --outputFile tests.xml
  2. See error

Expected behavior
The output report file should be named using the --outputFile parameter value

Screenshots
image

System
Storybook Environment Info:

System:
OS: Windows 11 10.0.22000
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12800H
Binaries:
Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD <----- active
npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.5.1 - ~\AppData\Roaming\nvm\v18.12.1\pnpm.CMD
Browsers:
Edge: Spartan (44.22000.2600.0), Chromium (122.0.2365.92)
npmPackages:
@storybook/addon-a11y: ^8.0.0 => 8.0.0
@storybook/addon-designs: ^7.0.9 => 7.0.9
@storybook/addon-essentials: ^8.0.0 => 8.0.0
@storybook/addon-interactions: ^8.0.0 => 8.0.0
@storybook/addon-links: ^8.0.0 => 8.0.0
@storybook/addon-mdx-gfm: 8.0.0 => 8.0.0
@storybook/blocks: ^8.0.0 => 8.0.0
@storybook/react: ^8.0.0 => 8.0.0
@storybook/react-vite: ^8.0.0 => 8.0.0
@storybook/test: 8.0.0 => 8.0.0
@storybook/test-runner: ^0.17.0 => 0.17.0
eslint-plugin-storybook: ^0.8.0 => 0.8.0
storybook: ^8.0.0 => 8.0.0

Additional context
Add any other context about the problem here.

@squidjam squidjam changed the title [bug] outpug [bug] outputFile parameter not working when --junit parameter is issued Mar 20, 2024
@squidjam squidjam changed the title [bug] outputFile parameter not working when --junit parameter is issued [bug] the --outputFile parameter is not working when --junit parameter is issued Mar 20, 2024
@yannbf
Copy link
Member

yannbf commented May 17, 2024

Hey @squidjam thanks for reporting this! I don't think it's an actual issue 🤔

1 - the --outputFile parameter is supposed to be used for the --json mode of jest, to specify the name of the json file, not junit. You can test it like so: yarn test-storybook --json -- --outputFile="tests.json"
2 - For junit, you can configure it via environment variables, check their docs: https://www.npmjs.com/package/jest-junit#configuration
So JEST_JUNIT_OUTPUT_NAME="testing.xml" yarn test-storybook --junit would generate the correct result:
image

@yannbf yannbf added the question Further information is requested label May 17, 2024
@squidjam
Copy link
Author

squidjam commented May 19, 2024

Hello, thank you for your answer.
My use case looks to produce separate junit files (one for a11y, another for visual regression testing) so being able to name them is part of it.
I would love that junit output was also possible using the same parameter to have a named file, otherwise one run will overwrite the other.
I'll try your recommendation.
Thanks.

@yannbf
Copy link
Member

yannbf commented May 20, 2024

Hello, thank you for your answer. My use case looks to produce separate junit files (one for a11y, another for visual regression testing) so being able to name them is part of it. I would love that junit output was also possible using the same parameter to have a named file, otherwise one run will overwrite the other. I'll try your recommendation. Thanks.

Thanks for explaining! Would you mind sharing a minimal reproduction so I can take a look at?

@squidjam
Copy link
Author

Hello, thank you for your answer. My use case looks to produce separate junit files (one for a11y, another for visual regression testing) so being able to name them is part of it. I would love that junit output was also possible using the same parameter to have a named file, otherwise one run will overwrite the other. I'll try your recommendation. Thanks.

Thanks for explaining! Would you mind sharing a minimal reproduction so I can take a look at?

Thanks, after further reading, the way described by you should be the right way to do it. Cheers.

For future reference:
https://www.npmjs.com/package/jest-junit#user-content-configuration
(scroll down a little and you'll find the parameter).

I just thought it would be easier to pass through the parameter --output and have test-runner reroute it as the JEST_JUNIT_OUTPUT_NAME="name.xml" when it invokes junit itself.
Closing because your answer is the right one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants