Fixed global error handling when the env is executed repeatedly

This commit is contained in:
Steve Gravrock
2025-09-06 10:32:56 -07:00
parent 62b5698a99
commit 3493519c9f
3 changed files with 67 additions and 16 deletions

View File

@@ -31,12 +31,21 @@ getJasmineRequireObj().Env = function(j$) {
// before it's set to detect load-time errors in browsers
() => this.configuration()
);
const installGlobalErrors = (function() {
const { installGlobalErrors, uninstallGlobalErrors } = (function() {
let installed = false;
return function() {
if (!installed) {
globalErrors.install();
installed = true;
return {
installGlobalErrors() {
if (!installed) {
globalErrors.install();
installed = true;
}
},
uninstallGlobalErrors() {
if (installed) {
globalErrors.uninstall();
installed = false;
}
}
};
})();
@@ -960,9 +969,7 @@ getJasmineRequireObj().Env = function(j$) {
};
this.cleanup_ = function() {
if (globalErrors) {
globalErrors.uninstall();
}
uninstallGlobalErrors();
};
}