Skip to content
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: run afterEach hooks in correct order #52239

Merged
merged 1 commit into from
Mar 30, 2024

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Mar 28, 2024

This commit updates the test runner afterEach hook so that the current test's afterEach hooks run before any ancestor afterEach hooks.

Fixes: #51671

This commit updates the test runner afterEach hook so that the
current test's afterEach hooks run before any ancestor afterEach
hooks.

Fixes: nodejs#51671
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Mar 28, 2024
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 28, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 28, 2024
@nodejs-github-bot
Copy link
Collaborator

Comment on lines +565 to +566
ArrayPrototypeSplice(this.hooks[name], this.hooks.ownAfterEachCount, 0, hook);
this.hooks.ownAfterEachCount++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ArrayPrototypeSplice(this.hooks[name], this.hooks.ownAfterEachCount, 0, hook);
this.hooks.ownAfterEachCount++;
ArrayPrototypeSplice(this.hooks[name], this.hooks.ownAfterEachCount++, 0, hook);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally find that a little less readable, only because the splice line is already a bit busy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, works for me 🙂

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. and removed needs-ci PRs that need a full CI run. labels Mar 28, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 30, 2024
@nodejs-github-bot nodejs-github-bot merged commit 7c02486 into nodejs:main Mar 30, 2024
66 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 7c02486

@cjihrig cjihrig deleted the after-each-order branch March 30, 2024 13:18
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
This commit updates the test runner afterEach hook so that the
current test's afterEach hooks run before any ancestor afterEach
hooks.

Fixes: #51671
PR-URL: #52239
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 3, 2024
This commit updates the test runner afterEach hook so that the
current test's afterEach hooks run before any ancestor afterEach
hooks.

Fixes: #51671
PR-URL: #52239
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Order of nested vs outer afterEach hooks is unexpected and inconsistent with after
4 participants