enable --no-isolate to speed up unit tests

This required fixing deferred code that was running after the unit test had unmounted
This commit is contained in:
Kyle Hensel
2024-09-09 20:20:12 +10:00
committed by Martin Raifer
parent e839b63079
commit 108893c624
4 changed files with 10 additions and 1 deletions

View File

@@ -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.

View File

@@ -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';

View File

@@ -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": {

View File

@@ -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() {