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

Add number of timeouts in test summary #3021

Merged
merged 4 commits into from
May 16, 2022
Merged

Conversation

il3ven
Copy link
Contributor

@il3ven il3ven commented May 8, 2022

This PR adds a line in test summary to indicate the number of tests that failed due to timeout. Fixes #2639.

5 tests remained pending after a timeout

I have modified stats.timeout to represent the number of timed-out tests. I couldn't find what stats.timeout was supposed to represent but I changed it to what I expect from it by looking at the context.

diff --git a/lib/run-status.js b/lib/run-status.js
index a18f4e1af..b6128cda7 100644
--- a/lib/run-status.js
+++ b/lib/run-status.js
@@ -125,7 +125,10 @@ export default class RunStatus extends Emittery {
 			case 'timeout':
 				event.pendingTests = this.pendingTests;
 				this.pendingTests = new Map();
-				stats.timeouts++;
+				for (const [, testsInFile] of event.pendingTests.entries()) {
+					stats.timeouts += testsInFile.size;
+				}
+
 				break;
 			case 'interrupt':
 				event.pendingTests = this.pendingTests;
Sample terminal output
ava-test-timed-out git:(master) ✗ npx ava

  ✔ another test that is simply passing
  
  ✖ Timed out while running tests

  1 tests were pending in test/index_test.js

  ◌ a test that times out



  1 test passed
  1 test remained pending after a timeout

This output is the result of running https://github.com/TimDaub/ava-test-timed-out/blob/master/test/index_test.js.

@il3ven il3ven force-pushed the timeout-report branch 3 times, most recently from ff58807 to 5d0cdd7 Compare May 8, 2022 20:56
Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

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

Great!

@novemberborn novemberborn changed the title add number of timeouts in test summary Add number of timeouts in test summary May 16, 2022
@novemberborn novemberborn merged commit 714c474 into avajs:main May 16, 2022
@il3ven il3ven deleted the timeout-report branch May 16, 2022 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"✖ Timed out while running tests" are not reported as failing tests
2 participants