Skip to content

Commit

Permalink
fix unhandled rejection if transform fails
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 28, 2021
1 parent e9af0b0 commit 0ad5b71
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/jest-transform/src/ScriptTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -773,30 +773,30 @@ class ScriptTransformer {
},
},
);
const module: ModuleType = await requireOrImportModule(
moduleName,
applyInteropRequireDefault,
);
try {
const module: ModuleType = await requireOrImportModule(
moduleName,
applyInteropRequireDefault,
);

if (!callback) {
revertHook();
if (!callback) {
revertHook();

return module;
}
return module;
}

try {
const cbResult = callback(module);

if (isPromise(cbResult)) {
return waitForPromiseWithCleanup(cbResult, revertHook).then(
() => module,
);
}

return module;
} finally {
revertHook();
}

return module;
}

shouldTransform(filename: Config.Path): boolean {
Expand Down

0 comments on commit 0ad5b71

Please sign in to comment.