test(spec): install fake runtime via defineProperty to survive locked global

This commit is contained in:
pj committed 2026-06-01 21:24:38 +05:30
1 parent 80e7e71e7a
commit 451d8c6751
1 file changed
+9 -1
+9 -1
View File
@@ -132,7 +132,15 @@ function installFakeRuntime(): RecordedRuntime {
},
};
const recorded = Object.assign(runtime, calls) as RecordedRuntime;
globalThis.__sanderling__ = recorded;
// web-runtime.ts locks __sanderling__ as non-writable (configurable) when it
// is imported earlier in the same bun-test process, so a plain assignment
// would throw. defineProperty installs (and reinstalls) the fake regardless.
Object.defineProperty(globalThis, "__sanderling__", {
value: recorded,
writable: false,
configurable: true,
enumerable: false,
});
return recorded;
}