-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
test_runner: add timeout support to test plan #56765
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e9a7a7f
test_runner: refactor testPlan counter increse
pmarchini 9735384
test_runner: add timeout support to test plan
pmarchini c942eb9
test_runner: add input validation tests and refactor planning with wait
pmarchini 927ffdb
test_runner: refactor TestPlan
pmarchini 0665597
doc: add plan wait option to test runner documentation
pmarchini 295bd0f
test_runner: remove poller
pmarchini 53fcd1e
test_runner: refactor TestPlan constructor
pmarchini 20cfb75
test_runner: refactor namings
pmarchini 33993c8
doc: update plan wait option documentation
pmarchini 90e566f
test: remove platformTimeout
pmarchini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test_runner: add input validation tests and refactor planning with wait
- Loading branch information
commit c942eb9cc1bcb7384dd0de5938cb55ff9ee16d76
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 56 additions & 25 deletions
81
test/fixtures/test-runner/output/test-runner-plan-timeout.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,65 @@ | ||
| 'use strict'; | ||
| const { describe, it } = require('node:test'); | ||
| const { setTimeout } = require('node:timers/promises'); | ||
| const { platformTimeout } = require('../../../common'); | ||
|
|
||
| describe('planning with timeout', () => { | ||
| it(`planning should pass if plan it's correct`, async (t) => { | ||
| t.plan(1, { timeout: 500_000_000 }); | ||
| t.assert.ok(true); | ||
| describe('planning with wait', () => { | ||
| it('planning with wait and passing', async (t) => { | ||
| t.plan(1, { wait: platformTimeout(5000) }); | ||
|
|
||
| const asyncActivity = () => { | ||
| setTimeout(() => { | ||
| t.assert.ok(true); | ||
| }, platformTimeout(250)); | ||
| }; | ||
|
|
||
| asyncActivity(); | ||
| }); | ||
|
|
||
| it(`planning should fail if plan it's incorrect`, async (t) => { | ||
| t.plan(1, { timeout: 500_000_000 }); | ||
| t.assert.ok(true); | ||
| t.assert.ok(true); | ||
|
|
||
| it('planning with wait and failing', async (t) => { | ||
| t.plan(1, { wait: platformTimeout(5000) }); | ||
|
|
||
| const asyncActivity = () => { | ||
| setTimeout(() => { | ||
| t.assert.ok(false); | ||
| }, platformTimeout(250)); | ||
| }; | ||
|
|
||
| asyncActivity(); | ||
| }); | ||
|
|
||
| it('planning wait time expires before plan is met', async (t) => { | ||
| t.plan(2, { wait: platformTimeout(500) }); | ||
|
|
||
| const asyncActivity = () => { | ||
| setTimeout(() => { | ||
| t.assert.ok(true); | ||
| }, platformTimeout(50_000_000)); | ||
| }; | ||
|
|
||
| asyncActivity(); | ||
| }); | ||
|
|
||
| it('planning with timeout', async (t) => { | ||
| t.plan(1, { timeout: 2000 }); | ||
|
|
||
| while (true) { | ||
| await setTimeout(5000); | ||
| } | ||
|
|
||
| it(`planning with wait "options.wait : true" and passing`, async (t) => { | ||
| t.plan(1, { wait: true }); | ||
|
|
||
| const asyncActivity = () => { | ||
| setTimeout(() => { | ||
| t.assert.ok(true); | ||
| }, platformTimeout(250)); | ||
| }; | ||
|
|
||
| asyncActivity(); | ||
| }); | ||
|
|
||
| it('nested planning with timeout', async (t) => { | ||
| t.plan(1, { timeout: 2000 }); | ||
|
|
||
| t.test('nested', async (t) => { | ||
| while (true) { | ||
| await setTimeout(5000); | ||
| } | ||
| }); | ||
| it(`planning with wait "options.wait : true" and failing`, async (t) => { | ||
| t.plan(1, { wait: true }); | ||
|
|
||
| const asyncActivity = () => { | ||
| setTimeout(() => { | ||
| t.assert.ok(false); | ||
| }, platformTimeout(250)); | ||
| }; | ||
|
|
||
| asyncActivity(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.