mirror of
https://github.com/screentinker/screentinker.git
synced 2026-08-13 22:03:13 -06:00
Fix the only test that fails on Node 22
Node 22 added a built-in `navigator` global, defined as a getter with no setter. The test's shim assigned to it, which throws "only a getter" under 'use strict' on 22 while being a normal assignment on Node 20, where the global does not exist at all. It is configurable, so define it instead of assigning. Defining it unconditionally is also the better fixture: Node 22's own navigator reports the HOST locale, so a test reading its language would otherwise depend on the machine or CI runner it happens to run on. This was the single failure in an otherwise clean Node 22 run (1639/1640 with better-sqlite3 12.9.0), and it is confined to test code — no production server or frontend file assigns to globalThis.navigator. 1649/1649 on Node 20.
This commit is contained in:
parent
ba33b26a96
commit
03420ebc90
|
|
@ -24,7 +24,15 @@ globalThis.localStorage = {
|
|||
removeItem: (k) => store.delete(k),
|
||||
clear: () => store.clear(),
|
||||
};
|
||||
globalThis.navigator = globalThis.navigator || { language: 'en' };
|
||||
// Node 22 added a built-in `navigator` global, defined as a getter with NO setter — so the plain
|
||||
// assignment this used to do throws ("only a getter") under 'use strict' there, while being fine on
|
||||
// Node 20 where the global does not exist at all. It is configurable, so define it rather than
|
||||
// assign. Doing that unconditionally is also the more honest fixture: Node 22's own navigator
|
||||
// reports the HOST locale (en-US here, something else on another machine or in CI), and a test that
|
||||
// reads its language should not depend on where it runs.
|
||||
Object.defineProperty(globalThis, 'navigator', {
|
||||
value: { language: 'en' }, configurable: true, writable: true,
|
||||
});
|
||||
|
||||
const MOD = pathToFileURL(path.join(__dirname, '..', '..', 'frontend', 'js', 'components', 'getting-started.js')).href;
|
||||
let GS;
|
||||
|
|
|
|||
Loading…
Reference in a new issue