diff --git a/modules/renderer/map.js b/modules/renderer/map.js index 0e5a7127c..a288aef41 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -653,6 +653,9 @@ export function rendererMap(context) { function redraw(difference, extent) { + // in unit tests, we need to abort if the test has already completed + if (typeof window === 'undefined') return; + if (surface.empty() || !_redrawEnabled) return; // If we are in the middle of a zoom/pan, we can't do differenced redraws. diff --git a/modules/util/session_mutex.js b/modules/util/session_mutex.js index 99fdc94d9..42b61edca 100644 --- a/modules/util/session_mutex.js +++ b/modules/util/session_mutex.js @@ -8,6 +8,9 @@ export function utilSessionMutex(name) { var intervalID; function renew() { + // in unit tests, we need to abort if the test has already completed + if (typeof window === 'undefined') return; + var expires = new Date(); expires.setSeconds(expires.getSeconds() + 5); document.cookie = name + '=1; expires=' + expires.toUTCString() + '; sameSite=strict'; diff --git a/package.json b/package.json index 13f4cf024..b9e01621d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "start:watch": "run-p build:js:watch start:server", "start:server": "node scripts/server.js", "test": "npm-run-all -s lint build test:spec", - "test:spec": "vitest", + "test:spec": "vitest --no-isolate", "translations": "node scripts/update_locales.js" }, "dependencies": { diff --git a/test/spec/services/panoramax.js b/test/spec/services/panoramax.js index e41850904..c69575451 100644 --- a/test/spec/services/panoramax.js +++ b/test/spec/services/panoramax.js @@ -21,6 +21,9 @@ describe('iD.servicePanoramax', function() { panoramax = iD.services.panoramax; panoramax.reset(); fetchMock.reset(); + + // never resolve + fetchMock.mock(/api\.panoramax\.xyz/, new Promise(() => {})); }); afterEach(function() {