-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support assertion message in
t.timeout()
Fixes #2443. Co-authored-by: Mark Wubben <mark@novemberborn.net>
- Loading branch information
1 parent
f72fab4
commit ca8ea45
Showing
11 changed files
with
109 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const test = require('ava'); | ||
|
||
test('timeout with custom message', async t => { | ||
t.timeout(10, 'time budget exceeded'); // eslint-disable-line ava/assertion-arguments | ||
await new Promise(() => {}); | ||
}); |
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const test = require('ava'); | ||
|
||
test('timeout with invalid message', t => { | ||
t.timeout(10, 20); // eslint-disable-line ava/assertion-arguments | ||
}); | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"ava": { | ||
"files": [ | ||
"*.js" | ||
] | ||
}, | ||
"dependencies": { | ||
"ava": "file:../../.." | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Snapshot report for `test/test-timeouts/test.js` | ||
|
||
The actual snapshot is saved in `test.js.snap`. | ||
|
||
Generated by [AVA](https://avajs.dev). | ||
|
||
## timeout messages must be strings | ||
|
||
> error message | ||
'The assertion message must be a string' | ||
|
||
> formatted values | ||
[ | ||
{ | ||
formatted: '20', | ||
label: 'Called with:', | ||
}, | ||
] |
Binary file not shown.
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const test = require('@ava/test'); | ||
const exec = require('../helpers/exec'); | ||
|
||
test('timeout message can be specified', async t => { | ||
const result = await t.throwsAsync(exec.fixture('custom-message.js')); | ||
const error = result.stats.getError(result.stats.failed[0]); | ||
t.is(error.message, 'time budget exceeded'); | ||
}); | ||
|
||
test('timeout messages must be strings', async t => { | ||
const result = await t.throwsAsync(exec.fixture('invalid-message.js')); | ||
const error = result.stats.getError(result.stats.failed[0]); | ||
t.snapshot(error.message, 'error message'); | ||
t.snapshot(error.values, 'formatted values'); | ||
}); |