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(config): make config.get() work from tests/page objects under tsx/cjs (#5635)
The internal API `config` imported via `import { config } from "codeceptjs"`
returned an empty object `{}` from tests, page objects and fragments, while it
worked from helpers.
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 a
test importing `config` gets a second, disconnected CJS copy of config.js whose
module-scoped `config` is an empty `{}` that the runner never populates. Helpers
don't hit this because they are loaded via import() (the ESM realm) and share the
live singleton.
Bridge the live config through globalThis, the same way recorder.js and
container.js were fixed in #5634: setConfig() mirrors the config onto
globalThis.__codeceptjs_config on every create/append/reset, and Config.get()
prefers it, falling back to the local module copy. Under pure ESM both point at
the same object, so there is no behavior change on the ESM path.
Adds a runner regression test driving a real tsx/cjs project that asserts a test
(CJS realm) and a helper (ESM realm) both read the live config. It fails without
the fix and passes with it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments