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: report failing tests after summary #47164

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

HinataKah0
Copy link
Contributor

@HinataKah0 HinataKah0 commented Mar 19, 2023

Re-output failing tests after summary has been printed. This behavior follows other popular test runners (e.g. jest, mocha, etc...).

Updated SpecReporter:

  1. When there is a 'test:fail' event, the test will be stored.
  2. After no more input, all the failed tests will be flushed.
  3. Extract the logic for formatting a test report into a re-usable function.

Fixes: #47110

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 19, 2023
@@ -655,6 +655,8 @@ class Test extends AsyncResource {
this.reporter.coverage(this.nesting, kFilename, this.harness.coverage);
}

this.reporter.endOfTests();
Copy link
Member

@MoLow MoLow Mar 19, 2023

Choose a reason for hiding this comment

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

use _flush to spare this change

@MoLow
Copy link
Member

MoLow commented Mar 19, 2023

thanks for your contribution! I have left some comments

@HinataKah0
Copy link
Contributor Author

I've addressed the comments.

Thanks for the feedbacks, I learned a few things! 😄

And I found a minor issue, if duration_ms is not printed, the text color is not reset.

Screenshot 2023-03-21 at 6 58 40 PM
^ I tried the main branch

Shall we fix it in this PR? Or it is better to open another PR to address this specific issue?
The latter is tidier in workflow.

@MoLow
Copy link
Member

MoLow commented Mar 21, 2023

Shall we fix it in this PR? Or it is better to open another PR to address this specific issue?

better to fix in a seperate PR

@HinataKah0 HinataKah0 force-pushed the report-failing-tests branch 2 times, most recently from 62f9aa5 to 55a4b28 Compare March 21, 2023 15:37
Copy link
Member

@MoLow MoLow left a comment

Choose a reason for hiding this comment

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

LGTM, bet there seems to be lint issues

color = gray;
symbol = symbols['hyphen:minus'];
}
return `${prefix}${indent}${color}${symbol}${title}${error}${white}`;
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
return `${prefix}${indent}${color}${symbol}${title}${error}${white}`;
return `${prefix}${indent}${color}${symbol}${title}${white}${error}`;

this is the fix for #47164 (comment)
since it is a small fix, I think it would be ok to include it in this PR

Copy link
Contributor Author

@HinataKah0 HinataKah0 Mar 22, 2023

Choose a reason for hiding this comment

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

Shall we add a test for this as well? In test/pseudo-tty/test_runner_default_reporter.out.

test('parent', () => {
  test('should fail', () => { throw new Error('fail'); });
  test('should pass but parent fail', () => {});
});

Re-output failing tests after summary has been printed.
This behavior follows other popular test runners
(e.g. jest, mocha, etc...).

Updated SpecReporter:
1. When there is a 'test:fail' event, the test will be
stored.
2. After no more input, all the failed tests will be
flushed.
3. Extract the logic for formatting a test report
into a re-usable function.

Fixes: nodejs#47110
@HinataKah0
Copy link
Contributor Author

HinataKah0 commented Mar 22, 2023

  • Resolved lint error (extracted the code to handle test report event and called it in both test:pass and test:fail)
  • Rebased to resolve conflicts because of adding test

[90m at *[39m
[90m at *[39m

[31m✖ should pass but parent fail [90m(*ms)[39m[39m
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
[31m should pass but parent fail [90m(*ms)[39m[39m
[31m* should pass but parent fail [90m(*ms)[39m[39m

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah...

Thanks for catching this, I totally missed it. 😨
Let me verify again.

@MoLow MoLow added commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. test_runner Issues and PRs related to the test runner subsystem. labels Mar 22, 2023
Upon 'test:fail', text color is not reset correctly
if duration is not printed.
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 23, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 23, 2023
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 23, 2023
@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 23, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 23, 2023
@nodejs-github-bot nodejs-github-bot merged commit 2e8f8eb into nodejs:main Mar 23, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 2e8f8eb

RafaelGSS pushed a commit that referenced this pull request Apr 5, 2023
Re-output failing tests after summary has been printed.
This behavior follows other popular test runners
(e.g. jest, mocha, etc...).

Updated SpecReporter:
1. When there is a 'test:fail' event, the test will be
stored.
2. After no more input, all the failed tests will be
flushed.
3. Extract the logic for formatting a test report
into a re-usable function.

Fixes: #47110
PR-URL: #47164
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request Apr 6, 2023
RafaelGSS pushed a commit that referenced this pull request Apr 7, 2023
Re-output failing tests after summary has been printed.
This behavior follows other popular test runners
(e.g. jest, mocha, etc...).

Updated SpecReporter:
1. When there is a 'test:fail' event, the test will be
stored.
2. After no more input, all the failed tests will be
flushed.
3. Extract the logic for formatting a test report
into a re-usable function.

Fixes: #47110
PR-URL: #47164
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@HinataKah0 HinataKah0 deleted the report-failing-tests branch May 14, 2023 09:33
danielleadams pushed a commit that referenced this pull request Jul 6, 2023
Re-output failing tests after summary has been printed.
This behavior follows other popular test runners
(e.g. jest, mocha, etc...).

Updated SpecReporter:
1. When there is a 'test:fail' event, the test will be
stored.
2. After no more input, all the failed tests will be
flushed.
3. Extract the logic for formatting a test report
into a re-usable function.

Fixes: #47110
PR-URL: #47164
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
cjihrig added a commit to cjihrig/node that referenced this pull request Mar 22, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: nodejs#47164
nodejs-github-bot pushed a commit that referenced this pull request Mar 25, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: #47164
PR-URL: #52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
nodejs-github-bot pushed a commit that referenced this pull request Mar 25, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: #52185
Refs: #47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
anonrig pushed a commit to anonrig/node that referenced this pull request Mar 25, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: nodejs#47164
PR-URL: nodejs#52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
anonrig pushed a commit to anonrig/node that referenced this pull request Mar 25, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: nodejs#52185
Refs: nodejs#47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: nodejs#47164
PR-URL: nodejs#52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: nodejs#52185
Refs: nodejs#47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: #47164
PR-URL: #52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: #52185
Refs: #47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 3, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: #47164
PR-URL: #52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 23, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: #52185
Refs: #47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
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. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: report failing tests at the bottom of the spec reporter
4 participants