diff --git a/tests/frontend/service_tile.test.js b/tests/frontend/service_tile.test.js index 4c3ebf3..3660bd7 100644 --- a/tests/frontend/service_tile.test.js +++ b/tests/frontend/service_tile.test.js @@ -1,7 +1,22 @@ -// @vitest-environment jsdom -import { describe, it, expect } from 'vitest'; +import { describe, it, expect, beforeAll, afterAll } from 'vitest'; +import { JSDOM } from 'jsdom'; import { serviceTile } from '../../public/components/service_tile.js'; +// Provide a DOM via jsdom WITHOUT switching this file to the `jsdom` vitest +// environment — a second environment makes vitest run a parallel worker pool that +// collides with the DB-backed node tests on the shared test database. We set the +// globals dom.js needs (document/Node) for this file only and tear them down after. +beforeAll(() => { + const dom = new JSDOM('', { url: 'http://localhost/' }); + global.window = dom.window; + global.document = dom.window.document; + global.Node = dom.window.Node; + global.location = dom.window.location; // safeHref() resolves against location.origin +}); +afterAll(() => { + delete global.window; delete global.document; delete global.Node; delete global.location; +}); + const base = { id: 'gramps', name: 'Gramps', host: 'ct109', icon: 'gramps', status: 'ok', url: 'http://192.168.1.99', external: 'https://gramps.hynesy.com' };