Skip to content

Commit c909094

Browse files
committed
test: improve localStorage mock to fix failing test case
1 parent 1b8db9b commit c909094

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/common/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,15 @@ const knownGlobals = new Set([
318318
'sessionStorage',
319319
].forEach((i) => {
320320
if (i === 'localStorage') {
321-
if (Object.hasOwn(globalThis, i)) {
322-
globalThis[i] = {};
323-
knownGlobals.add(globalThis[i]);
324-
}
321+
Object.defineProperty(globalThis, i, {
322+
configurable: true,
323+
enumerable: true,
324+
get() {
325+
return undefined;
326+
},
327+
});
328+
329+
knownGlobals.add(globalThis[i]);
325330
} else if (globalThis[i] !== undefined) {
326331
knownGlobals.add(globalThis[i]);
327332
}

0 commit comments

Comments
 (0)