-
Notifications
You must be signed in to change notification settings - Fork 74
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]: running nyc
in reportCoverage()
fails on Windows with factory file associations settings
#459
Comments
Hey @pyryk thanks for reporting this, and for being so detailed about it! The previous implementation you mentioned actually never worked. As coverage generation runs in the process exit (which should be sync), the previous implementation, given it was asynchronous, would actually be lost and not execute. Your suggestion for running node is pretty good, I'm not sure about potential downsides either. |
@pyryk I made a canary release containing the fix. Would you please try it out?
|
Thank you for such a quick response! I personally don't have a Windows machine I could test this on, but I asked a colleague to try the canary version. I'll let you know as soon as they've tried it. |
Hey @pyryk this is now released in version 0.18.1, please try it out! |
@yannbf the colleague just confirmed that the updated version works correctly on Windows even with default file associations. Thank you for taking the time to fix this! (I suppose it is now OK to close this, please reopen if there is a need for that) |
Amazing to hear! Thank you so much for reporting! |
Describe the bug
On Windows, with default Windows settings, generating the coverage report fails due to a Windows Script Host error.
When generating test coverage, the Storybook Test Runner runs the
nyc
command by executing the nyc.js file directly, rather than explicitly calling node with the file name as an argument. This works on systems that support the shebang directive, but AFAIK, on Windows, there is no shebang directive support. Therefore, Windows can only run the file based on the global file associations settings. Incidentally, the default file association for .js files is notnode
but the Windows Script Host. Unsurprisingly, the Windows Script Host is not able to interpret or run the nyc.js file.Since the file associations on Windows are global to the system and prone to change and/or reset over time, I'd argue it would be beneficial to cross-platform compatibility if the test-runner coverage report function would not rely on those settings.
The previous test-runner version (0.17.0) tried to determine the running environment based on the package manager used. Is there a specific reason this approach was removed? As far as I understand, this approach also worked on Windows irrespective of file association settings. Another option would probably be explicitly calling
node
with the nyc.js file path as an argument (although I'm not sure if this approach would have some other downsides)To Reproduce
Prerequisites: install node@20 on Windows 10 or 11
npm run test-storybook
with coverage enabled(Actual) A Windows Script Host error popup is shown with message "Microsoft JScript compilation error: invalid character in file nyc.js on line 1, char 1" (paraphrased)
System
Additional context
No response
The text was updated successfully, but these errors were encountered: