Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): tests should fail if has
process.exit
or unresolved Prom…
…ises (#207) * A test that exits early should fail Fixes #206 Also fixes the case where a test calls process.exit(0) itself, as that's essentially the same thing. * Apply suggestions from code review * wrap exit listener; merge test files Co-authored-by: Luke Edwards <luke.edwards05@gmail.com>
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { test } from 'uvu'; | ||
|
||
// TODO: test.fail() modifier (see #47) | ||
|
||
// A test that calls process.exit must fail (even if it exits with 0). | ||
// Otherwise all tests might not run, or even all assertions within test. | ||
test('should fail if `process.exit` encountered', async () => { | ||
process.exit(0); | ||
}); | ||
|
||
// This promise will never resolve & the process will exit early. | ||
// This must fail, otherwise all tests/assertions might not run. | ||
test('should fail if Promise never resolves :: GC', async () => { | ||
await new Promise(() => {}); | ||
}); | ||
|
||
test.run(); |
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