-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Order of test hooks seems wrong, and is different to the order of hooks for a describe suite #47915
Labels
test_runner
Issues and PRs related to the test runner subsystem.
test
Issues and PRs related to the tests.
Comments
VoltrexKeyva
added
test_runner
Issues and PRs related to the test runner subsystem.
test
Issues and PRs related to the tests.
labels
May 8, 2023
I am interested 🚀 |
The behavior definitely seems wrong (seems like order of hooks should have been different in https://github.com/nodejs/node/pull/47586/files). @philnash if you are interested in helping out, feel free to submit a PR |
Thanks @MoLow. I'll see what I can do with it! |
philnash
added a commit
to philnash/node
that referenced
this issue
May 9, 2023
For tests with subtests the before hook was being run after the beforeEach hook, which is the opposite to test suites and expectations. Also, a function was being used to close over the after hooks, but at the point it was being run the after hooks were not yet set up. Fixes nodejs#47915
philnash
added a commit
to philnash/node
that referenced
this issue
May 9, 2023
For tests with subtests the before hook was being run after the beforeEach hook, which is the opposite to test suites and expectations. Also, a function was being used to close over the after hooks, but at the point it was being run the after hooks were not yet set up. Fixes nodejs#47915
nodejs-github-bot
pushed a commit
that referenced
this issue
May 11, 2023
For tests with subtests the before hook was being run after the beforeEach hook, which is the opposite to test suites and expectations. Also, a function was being used to close over the after hooks, but at the point it was being run the after hooks were not yet set up. Fixes #47915 PR-URL: #47931 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
targos
pushed a commit
that referenced
this issue
May 12, 2023
For tests with subtests the before hook was being run after the beforeEach hook, which is the opposite to test suites and expectations. Also, a function was being used to close over the after hooks, but at the point it was being run the after hooks were not yet set up. Fixes #47915 PR-URL: #47931 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
danielleadams
pushed a commit
that referenced
this issue
Jul 6, 2023
For tests with subtests the before hook was being run after the beforeEach hook, which is the opposite to test suites and expectations. Also, a function was being used to close over the after hooks, but at the point it was being run the after hooks were not yet set up. Fixes #47915 PR-URL: #47931 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MoLow
pushed a commit
to MoLow/node
that referenced
this issue
Jul 6, 2023
For tests with subtests the before hook was being run after the beforeEach hook, which is the opposite to test suites and expectations. Also, a function was being used to close over the after hooks, but at the point it was being run the after hooks were not yet set up. Fixes nodejs#47915 PR-URL: nodejs#47931 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
test_runner
Issues and PRs related to the test runner subsystem.
test
Issues and PRs related to the tests.
Version
20.1.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
This test in the test runner fixtures is intended to test the order in which test hooks run. The expected output is:
In this case the
before
hook runs after the firstbeforeEach
hook. And theafter
hook doesn't run at all as "after nested" isn't part of the array at all.Comparing this to the order of hooks from "describe hooks":
This shows that the first
before
hook runs before anybeforeEach
hooks and that the outsideafter
hook runs after all other hooks.I would have thought that this behaviour should match between
describe
suites and tests with subtests. Otherwise it is likely to be confusing to the user.How often does it reproduce? Is there a required condition?
This is reproduced in the test suite. I am questioning why this is the behaviour and if it should be different.
What is the expected behavior? Why is that the expected behavior?
I would expect the test for test hooks to look like this, and pass:
Additional information
If you agree that this is incorrect and should be fixed, I would love to be able to help out.
The text was updated successfully, but these errors were encountered: