fix: error reporting (#41249)
This commit is contained in:
committed by
GitHub
parent
24209a3629
commit
f4e1fe11fc
@ -528,14 +528,21 @@ async function createTestRunner(
|
||||
try {
|
||||
const { pass, err } = await evaluator.evaluate(testString, 5000);
|
||||
if (!pass) {
|
||||
throw new AssertionError(err.message);
|
||||
throw err;
|
||||
}
|
||||
} catch (err) {
|
||||
// add more info to the error so the failing test can be identified.
|
||||
text = 'Test text: ' + text;
|
||||
const message = solutionFromNext
|
||||
const newMessage = solutionFromNext
|
||||
? 'Check next step for solution!\n' + text
|
||||
: text;
|
||||
reThrow(err, message);
|
||||
// if the stack is missing, the message should be included. Otherwise it
|
||||
// is redundant.
|
||||
err.message = err.stack
|
||||
? newMessage
|
||||
: `${newMessage}
|
||||
${err.message}`;
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -578,13 +585,3 @@ async function initializeTestRunner(build, sources, code, loadEnzyme) {
|
||||
loadEnzyme
|
||||
);
|
||||
}
|
||||
|
||||
function reThrow(err, text) {
|
||||
const newMessage = `${text}
|
||||
${err.message}`;
|
||||
if (err.name === 'AssertionError') {
|
||||
throw new AssertionError(newMessage);
|
||||
} else {
|
||||
throw Error(newMessage);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user