From 451d8c6751d42c4f9a69c3edec6fa8743b62b301 Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 1 Jun 2026 21:24:38 +0530 Subject: [PATCH] test(spec): install fake runtime via defineProperty to survive locked global --- pkg/spec/test/api.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/spec/test/api.test.ts b/pkg/spec/test/api.test.ts index a2258fa..fde96a3 100644 --- a/pkg/spec/test/api.test.ts +++ b/pkg/spec/test/api.test.ts @@ -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; }