You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): make the whole internal API realm-agnostic under tsx/cjs (#5635)
Generalizes the config fix to every stateful internal-API singleton. The internal
API (config, container, recorder, event, store, output) is documented to work from
tests, page objects and fragments — not only helpers — but test files are loaded
through Mocha's synchronous require() (the CommonJS realm) under a CJS loader such as
tsx/cjs, while the framework runs as native ESM. So importing any of these from a test
loaded a second, disconnected CJS copy: config.get() returned {}, the container had no
helpers, the recorder was never started, the event dispatcher had no listeners. Helpers
were unaffected because they load via import() (the ESM realm).
Add lib/realm.js with realmSingleton(key, factory), which stores each singleton on
globalThis so every realm resolves to the one the runner operates on (the ESM runner
loads these modules first during bootstrap, so it wins the key; later CJS copies reuse
it). Apply it to recorder, container state, the event dispatcher, store and output, and
refactor config.js to the same holder pattern. Under pure ESM the modules load once, so
there is no behavior change.
Broadens the regression fixture to assert config/container/recorder/event/store all
resolve to the live singletons from a test imported via tsx/cjs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments