Skip to content

Commit

Permalink
Continue writing output.js when exec.js throws (#16278)
Browse files Browse the repository at this point in the history
defer exec error
  • Loading branch information
liuxingbaoyu committed Feb 14, 2024
1 parent 19c54cf commit bfefe70
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/babel-helper-transform-fixture-test-runner/src/index.ts
Expand Up @@ -301,6 +301,8 @@ async function run(task: Test) {
let result: FileResult;
let resultExec;

let execErr: Error;

if (execCode) {
const context = createTestContext();
const execOpts = getOpts(exec);
Expand All @@ -318,9 +320,13 @@ async function run(task: Test) {
resultExec = runCodeInTestContext(execCode, execOpts, context);
} catch (err) {
// Pass empty location to include the whole file in the output.
err.message =
`${exec.loc}: ${err.message}\n` + codeFrameColumns(execCode, {} as any);
throw err;
if (typeof err === "object" && err.message) {
err.message =
`${exec.loc}: ${err.message}\n` +
codeFrameColumns(execCode, {} as any);
}

execErr = err;
}
}

Expand Down Expand Up @@ -395,6 +401,10 @@ async function run(task: Test) {
}
}

if (execErr) {
throw execErr;
}

if (task.validateSourceMapVisual === true) {
const visual = visualizeSourceMap(result.code, result.map);
try {
Expand Down

0 comments on commit bfefe70

Please sign in to comment.