| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1455,7 +1455,9 @@ class Suite extends Test { | |||
| 1455 | 1455 | reportedType = 'suite'; | |
| 1456 | 1456 | constructor(options) { | |
| 1457 | 1457 | super(options); | |
| 1458 | - this.timeout = null; | ||
| 1458 | + if (options.timeout == null) { | ||
| 1459 | + this.timeout = null; | ||
| 1460 | + } | ||
| 1459 | 1461 | ||
| 1460 | 1462 | if (this.config.testNamePatterns !== null && | |
| 1461 | 1463 | this.config.testSkipPatterns !== null && | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,10 +2,10 @@ | |||
| 2 | 2 | const { describe, it, after } = require('node:test'); | |
| 3 | 3 | const { setTimeout } = require('node:timers'); | |
| 4 | 4 | ||
| 5 | - const timeoutRefs = []; | ||
| 5 | + describe('--test-timeout is set to 100ms', () => { | ||
| 6 | + const timeoutRefs = []; | ||
| 6 | 7 | ||
| 7 | - describe('--test-timeout is set to 20ms', () => { | ||
| 8 | - it('should timeout after 20ms', async () => { | ||
| 8 | + it('should timeout after 100ms', async () => { | ||
| 9 | 9 | const { promise, resolve } = Promise.withResolvers(); | |
| 10 | 10 | timeoutRefs.push(setTimeout(() => { | |
| 11 | 11 | resolve(); | |
@@ -37,3 +37,22 @@ describe('--test-timeout is set to 20ms', () => { | |||
| 37 | 37 | } | |
| 38 | 38 | }); | |
| 39 | 39 | }); | |
| 40 | + | ||
| 41 | + | ||
| 42 | + describe('should inherit timeout options to children', { timeout: 1 }, () => { | ||
| 43 | + const timeoutRefs = []; | ||
| 44 | + | ||
| 45 | + after(() => { | ||
| 46 | + for (const timeoutRef of timeoutRefs) { | ||
| 47 | + clearTimeout(timeoutRef); | ||
| 48 | + } | ||
| 49 | + }); | ||
| 50 | + | ||
| 51 | + it('should timeout after 1ms', async () => { | ||
| 52 | + const { promise, resolve } = Promise.withResolvers(); | ||
| 53 | + timeoutRefs.push(setTimeout(() => { | ||
| 54 | + resolve(); | ||
| 55 | + }, 20000)); | ||
| 56 | + await promise; | ||
| 57 | + }); | ||
| 58 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,13 @@ | |||
| 1 | 1 | TAP version 13 | |
| 2 | - # Subtest: --test-timeout is set to 20ms | ||
| 3 | - # Subtest: should timeout after 20ms | ||
| 4 | - not ok 1 - should timeout after 20ms | ||
| 2 | + # Subtest: --test-timeout is set to 100ms | ||
| 3 | + # Subtest: should timeout after 100ms | ||
| 4 | + not ok 1 - should timeout after 100ms | ||
| 5 | 5 | --- | |
| 6 | 6 | duration_ms: * | |
| 7 | 7 | type: 'test' | |
| 8 | 8 | location: '/test/fixtures/test-runner/output/test-timeout-flag.js:(LINE):3' | |
| 9 | 9 | failureType: 'testTimeoutFailure' | |
| 10 | - error: 'test timed out after 20ms' | ||
| 10 | + error: 'test timed out after 100ms' | ||
| 11 | 11 | code: 'ERR_TEST_FAILURE' | |
| 12 | 12 | stack: |- | |
| 13 | 13 | async Promise.all (index 0) | |
@@ -35,7 +35,7 @@ TAP version 13 | |||
| 35 | 35 | type: 'test' | |
| 36 | 36 | ... | |
| 37 | 37 | 1..4 | |
| 38 | - not ok 1 - --test-timeout is set to 20ms | ||
| 38 | + not ok 1 - --test-timeout is set to 100ms | ||
| 39 | 39 | --- | |
| 40 | 40 | duration_ms: * | |
| 41 | 41 | type: 'suite' | |
@@ -44,12 +44,33 @@ not ok 1 - --test-timeout is set to 20ms | |||
| 44 | 44 | error: '2 subtests failed' | |
| 45 | 45 | code: 'ERR_TEST_FAILURE' | |
| 46 | 46 | ... | |
| 47 | - 1..1 | ||
| 48 | - # tests 4 | ||
| 49 | - # suites 1 | ||
| 47 | + # Subtest: should inherit timeout options to children | ||
| 48 | + # Subtest: should timeout after 1ms | ||
| 49 | + not ok 1 - should timeout after 1ms | ||
| 50 | + --- | ||
| 51 | + duration_ms: * | ||
| 52 | + type: 'test' | ||
| 53 | + location: '/test/fixtures/test-runner/output/test-timeout-flag.js:(LINE):3' | ||
| 54 | + failureType: 'cancelledByParent' | ||
| 55 | + error: 'test did not finish before its parent and was cancelled' | ||
| 56 | + code: 'ERR_TEST_FAILURE' | ||
| 57 | + ... | ||
| 58 | + 1..1 | ||
| 59 | + not ok 2 - should inherit timeout options to children | ||
| 60 | + --- | ||
| 61 | + duration_ms: * | ||
| 62 | + type: 'suite' | ||
| 63 | + location: '/test/fixtures/test-runner/output/test-timeout-flag.js:(LINE):1' | ||
| 64 | + failureType: 'testTimeoutFailure' | ||
| 65 | + error: 'test timed out after 1ms' | ||
| 66 | + code: 'ERR_TEST_FAILURE' | ||
| 67 | + ... | ||
| 68 | + 1..2 | ||
| 69 | + # tests 5 | ||
| 70 | + # suites 2 | ||
| 50 | 71 | # pass 2 | |
| 51 | 72 | # fail 0 | |
| 52 | - # cancelled 2 | ||
| 73 | + # cancelled 3 | ||
| 53 | 74 | # skipped 0 | |
| 54 | 75 | # todo 0 | |
| 55 | 76 | # duration_ms * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,15 +137,15 @@ const tests = [ | |||
| 137 | 137 | name: 'test-runner/output/test-timeout-flag.js', | |
| 138 | 138 | flags: [ | |
| 139 | 139 | '--test-reporter=tap', | |
| 140 | - '--test-timeout=20', | ||
| 140 | + '--test-timeout=100', | ||
| 141 | 141 | ], | |
| 142 | 142 | }, | |
| 143 | 143 | // --test-timeout should work with or without --test flag | |
| 144 | 144 | { | |
| 145 | 145 | name: 'test-runner/output/test-timeout-flag.js', | |
| 146 | 146 | flags: [ | |
| 147 | 147 | '--test-reporter=tap', | |
| 148 | - '--test-timeout=20', | ||
| 148 | + '--test-timeout=100', | ||
| 149 | 149 | '--test', | |
| 150 | 150 | ], | |
| 151 | 151 | }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments