-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Standard assert error message changes when test is run through nyc #1142
Comments
Is it just showing node 8 error messages or is it actually running under node 8? Can the same happen if tests are run under node.js 12? If so we could test with Also I see that you are using I've got other things I have to look at this morning but I hope to investigate this afternoon. |
I think it's just showing the error message, process.version returns the expected node version number before each test regardless of nyc being involved. Just a quick note that I'm using nvm to switch between versions. The issue still occurs under node 12. I tried adding the node 12 class field with a simple getter and a test, both mocha and nyc/mocha had no issue with node 12 class fields but the assert message still differed, node 10 complained in both cases as you'd expect. Taking npx out of the picture and running with |
It appears that something is causing node.js to think it's in REPL when nyc is running. See https://nodejs.org/dist/latest/docs/api/assert.html#assert_assert_ok_value_message @bcoe do you have any ideas on this? Switching from nyc built-in instrumentation to babel-plugin-istanbul instrumenter does not fix the issue. |
@coreyfarrell @AndrewFinlay interesting, there's a lot of fiddling with the environment in |
@bcoe Configuring nyc with |
This comment has been minimized.
This comment has been minimized.
|
I seem to be getting some inconsistent results or maybe I ran it incorrectly earlier, now the error is not happening if I pre-instrument lib/assert.js then run under nyc with instrumentation disabled. |
I've spent some time digging into this and found that this is a NodeJS issue and not a nyc issue. It seems that the assert exception message changes depending on the whitespace surrounding the code generating it. This means that uninstrumented code will generate one result, while the minified instrumented result will generate another. If you unminify the instrumented source it will go back to the original result. I've put up an issue with a minimal reproduction on the NodeJS project here. As for current mitigations, if you include your own exception message |
Thanks for investigating, I'm glad to hear you found the cause. I'd like to leave this report open until a fix is implemented in node.js. |
We recently bumped into this issue when running our internal test suite against node 10, and found differences in the result between nyc/mocha and just mocha. I'm assuming that this is caused by one of nyc dependencies and not nyc itself, however I really don't know so I figure this is the best place for the report.
Link to bug demonstration repository
demo
Expected Behavior
When running tests under node v10, the assertion failure message should be the same when running
npx mocha --recursive --ui bdd ./test
andnpx nyc mocha --recursive --ui bdd ./test
Observed Behavior
Running the test under mocha produces the node 10 error message, while running the test under nyc and mocha produces the node 8 error message.
Troubleshooting steps
cache: false
in my nyc configEnvironment Information
The text was updated successfully, but these errors were encountered: