-
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.
Self-host the built-in Node.js assert tests
Also make `test-ava` work from inside the `test` directory. Co-authored-by: Mark Wubben <mark@novemberborn.net>
- Loading branch information
1 parent
5ddc9fd
commit 1150991
Showing
12 changed files
with
60 additions
and
55 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 was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...fixture/node-assertions/assert-failure.js → ...-nodejs-assert/fixtures/assert-failure.js
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,7 @@ | ||
{ | ||
"ava": { | ||
"files": [ | ||
"*.js" | ||
] | ||
} | ||
} |
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,25 @@ | ||
const test = require('@ava/test'); | ||
const exec = require('../helpers/exec'); | ||
|
||
test('node assertion failures are reported to the console when running in a terminal', async t => { | ||
const options = { | ||
env: { | ||
// The AssertionError constructor in Node.js 10 depends on the TTY interface, so opt-in | ||
// to it being simulated. | ||
AVA_SIMULATE_TTY: true, | ||
AVA_TTY_COLOR_DEPTH: 8 | ||
} | ||
}; | ||
|
||
const result = await t.throwsAsync(exec.fixture(['assert-failure.js'], options)); | ||
const error = result.stats.getError(result.stats.failed[0]); | ||
|
||
t.true(error.values.every(value => value.formatted.includes('AssertionError'))); | ||
}); | ||
|
||
test('node assertion failures are reported to the console when not running in a terminal', async t => { | ||
const result = await t.throwsAsync(exec.fixture(['assert-failure.js'])); | ||
const error = result.stats.getError(result.stats.failed[0]); | ||
|
||
t.true(error.values.every(value => value.formatted.includes('AssertionError'))); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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