test(health): use programmatic jsdom in node env to keep DB tests serial

A second vitest environment spins up a parallel worker pool that collides with the
DB-backed tests on the shared void_test database (fileParallelism only serializes
within one pool). Provide the DOM via jsdom directly instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-08 01:21:27 +10:00
parent d5adfb5054
commit 3881334a7b

View File

@@ -1,7 +1,22 @@
// @vitest-environment jsdom import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { describe, it, expect } from 'vitest'; import { JSDOM } from 'jsdom';
import { serviceTile } from '../../public/components/service_tile.js'; 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('<!doctype html><html><body></body></html>', { 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', const base = { id: 'gramps', name: 'Gramps', host: 'ct109', icon: 'gramps', status: 'ok',
url: 'http://192.168.1.99', external: 'https://gramps.hynesy.com' }; url: 'http://192.168.1.99', external: 'https://gramps.hynesy.com' };