-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
test_runner: before
hook runs even if it's not followed by any test
#53202
Comments
I've had the same thought but in reality just because you don't call any assertion it doesn't mean the test is not doing anything. |
|
I'm not sure I understand your point. I'll reopen to hear other collaborators opinion |
I think the current behavior for subtests is correct - |
My main problem is with suits, because unlike tests, they are not subject to
What do you mean by subtests? Don't you mean just tests? test('test without subtests', async () => {
before(async () => {
// runs after body1 and body2 (not before)
})
console.log('body1')
before(() => {
// runs after body1 (not before)
});
console.log('body2');
}) So you're saying it should always run, but I am asking before what it should always run? |
I think it basically boils down to whether
|
This appears to be fixed in v22. My guess is that #52221 being labeled semver-major is the reason it's not fixed in v20. |
Closing per my last comment. |
Version
v20.13.1
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
test_runner
What steps will reproduce the bug?
Execute with:
node --test --test-name-pattern="nonsence"
How often does it reproduce? Is there a required condition?
Always. No.
What is the expected behavior? Why is that the expected behavior?
before
hook shouldn't run if it's not followed by any test. There is no practial or logical reason to runbefore
hook alone, it wastes time and resources.What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: