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
sandbox.assert.fail
and sandbox.assert.pass
affect global sinon configuration
#2298
Comments
Is there any chance you can make this a runnable example? |
@mroderick Here you go: https://github.com/kim366/sinon-issue-concurrent. If you mark the tests with |
Great bug report with repro! Fearing that this might be tightly related to understanding AVA as well.
🤔 ... 🤯 Could you elaborate on that? Not sure I understand what you mean wrt how this |
@fatso83 Thank you. Let's call the
This is the least bad of the symptoms of this. It is also possible that in the output it tells you that another test failed! This is extremely confusing. When I set |
Line 413 in 332485a
The global assert is just being assigned to the sandbox |
Great find! This should be very possible to do something with. It's supposed to be the other way around: sinon's internal sandbox should of course assign its assert to sinon.assert, not the other way around. |
Well, I think the changes necessary are minimal. Instead of assert, it should do aomething along the lines of exporting a function |
I’ll see if I get around to doing a PR, but I’ll first have to understand the sinon project structure. Update: unfortunately I know old-style JS too little to know how do this without messing with imports. |
"Old style JS" is just JS, you know :) There is not much in the source code that would be different if using ES2020+, since it simply relies on on knowing how Javascript works and utilizes the mechanics of ECMAScript's prototypal nature. Hacking on Sinon made me understand how ES2015 classes actually worked under the hood, so it's a good exercise in becoming a better JS developer. Not sure what you mean by messing with imports, btw? In CommonJS style modules, like in Node, exports are bound at runtime, not at link time, so you can do quite a lot of manipulation that you cannot do with ES Modules. Not sure how that applies here, though ... ? |
Okay, sure, I'll try it again :) My problem was that I wanted to do |
@kim366 If you push your fork somewhere public and give the link I can have a look. |
I got it to work, in the end :) sorry for that |
This has been fixed with #2302 |
Describe the bug
sandbox.assert.fail
andsandbox.assert.pass
seem to not only affect the current sandbox, but the entire sinon environment. This becomes an issue when tests run concurrently, as they do in, e.g., AVA.To Reproduce
Steps to reproduce the behavior:
I created this function. When used in two AVA tests that run concurrently, AVA will either report
Error: Test finished without running any assertions
orError: Assertion passed, but test has already finished
.Expected behavior
The fail and pass bindings should only affect the current sandbox, that way they don't get overridden by concurrent tests.
Context
The text was updated successfully, but these errors were encountered: