Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure test run failures crash worker (#1265)
* Ensure Test#run() returns exit promise This allows errors from the exit logic to propagate to the runner. * Treat runner errors as uncaught exceptions Errors that occur inside the runner are treated as uncaught exceptions. This prevents them from being swallowed in the promise chain, causing the test to hang. * fixup! Treat runner errors as uncaught exceptions * fixup! Treat runner errors as uncaught exceptions
- Loading branch information
1 parent
f3b60f4
commit 9cea60d
Showing
8 changed files
with
80 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
require('../../../lib/serialize-error'); | ||
|
||
const serializeModule = require.cache[require.resolve('../../../lib/serialize-error')]; | ||
|
||
const original = serializeModule.exports; | ||
let restored = false; | ||
let restoreAfterFirstCall = false; | ||
serializeModule.exports = error => { | ||
if (restored) { | ||
return original(error); | ||
} | ||
if (restoreAfterFirstCall) { | ||
restored = true; | ||
} | ||
|
||
throw new Error('Forced error'); | ||
}; | ||
|
||
exports.restoreAfterFirstCall = () => { | ||
restoreAfterFirstCall = true; | ||
}; |
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,5 @@ | ||
{ | ||
"ava": { | ||
"require": "./hack.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,5 @@ | ||
import test from '../../../'; | ||
|
||
test(async () => { | ||
throw new Error('Hi :)'); | ||
}); |
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,8 @@ | ||
import test from '../../../'; | ||
|
||
import { restoreAfterFirstCall } from './hack'; | ||
restoreAfterFirstCall(); | ||
|
||
test(async () => { | ||
throw new Error('Hi :)'); | ||
}); |