mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-05 04:27:09 +00:00
test(spec): install fake runtime via defineProperty to survive locked global
This commit is contained in:
1 parent
80e7e71e7a
commit
451d8c6751
1 file changed
+9
-1
@@ -132,7 +132,15 @@ function installFakeRuntime(): RecordedRuntime {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const recorded = Object.assign(runtime, calls) as 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;
|
return recorded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user