mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 14:44:07 +00:00
* chore: update package-lock.json to include yaml dependency * feat: add script-aware stack traces and source context for script/test failures * chore: sync package-lock.json with yaml dependency in bruno-js * fix: handle null check in getErrorTypeName and align JSDoc style * refactor: derive script path from request.pathname and use SCRIPT_TYPES constant * fix: avoid showing source context for collection/folder script errors * feat: map collection/folder script errors to source file and line * fix: update error formatting and avoid undefined message * fix: resolve script block location in collection/folder yml files * refactor: use script wrapper utils and rename wrapper offsets * refactor: move script wrapper to utils, add wrapScriptInClosure fn
30 lines
814 B
JavaScript
30 lines
814 B
JavaScript
const Test = (__brunoTestResults, chai) => async (description, callback) => {
|
|
try {
|
|
await callback();
|
|
__brunoTestResults.addResult({ description, status: 'pass' });
|
|
} catch (error) {
|
|
if (error instanceof chai.AssertionError) {
|
|
const { message, actual, expected } = error;
|
|
__brunoTestResults.addResult({
|
|
description,
|
|
status: 'fail',
|
|
error: message,
|
|
actual,
|
|
expected,
|
|
stack: error.stack || null,
|
|
errorName: error.name || 'AssertionError'
|
|
});
|
|
} else {
|
|
__brunoTestResults.addResult({
|
|
description,
|
|
status: 'fail',
|
|
error: error.message || 'An unexpected error occurred.',
|
|
stack: error.stack || null,
|
|
errorName: error.name || 'Error'
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = Test;
|