mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-03 21:34:36 +01:00
27 lines
697 B
JavaScript
27 lines
697 B
JavaScript
|
const Test = (__brunoTestResults, chai) => (description, callback) => {
|
||
|
try {
|
||
|
callback();
|
||
|
__brunoTestResults.addResult({ description, status: "pass" });
|
||
|
} catch (error) {
|
||
|
console.log(chai.AssertionError);
|
||
|
if (error instanceof chai.AssertionError) {
|
||
|
const { message, actual, expected } = error;
|
||
|
__brunoTestResults.addResult({
|
||
|
description,
|
||
|
status: "fail",
|
||
|
error: message,
|
||
|
actual,
|
||
|
expected
|
||
|
});
|
||
|
} else {
|
||
|
__brunoTestResults.addResult({
|
||
|
description,
|
||
|
status: "fail",
|
||
|
error: error.message || 'An unexpected error occurred.'
|
||
|
});
|
||
|
}
|
||
|
console.log(error);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = Test;
|