Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue writing output.js when exec.js throws #16278

Merged
merged 1 commit into from Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 = createContext();
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