(dir, config, container)
| 15 | * Called from Codecept.initGlobals() |
| 16 | */ |
| 17 | export async function initCodeceptGlobals(dir, config, container) { |
| 18 | store.initialize({ |
| 19 | codeceptDir: dir, |
| 20 | outputDir: fsPath.resolve(dir, config.output), |
| 21 | }) |
| 22 | |
| 23 | store.noGlobals = config.noGlobals || false |
| 24 | store.maskSensitiveData = config.maskSensitiveData || false |
| 25 | |
| 26 | // Keep globals for backward compat with external plugins |
| 27 | global.codecept_dir = dir |
| 28 | global.output_dir = fsPath.resolve(dir, config.output) |
| 29 | |
| 30 | // pause/inject/share stay global even under noGlobals — they're the everyday |
| 31 | // debugging/wiring entry points and have no useful import alternative for |
| 32 | // page-object code that runs before the container is available. |
| 33 | global.pause = async (...args) => { |
| 34 | const pauseModule = await import('./pause.js') |
| 35 | return (pauseModule.default || pauseModule)(...args) |
| 36 | } |
| 37 | global.inject = () => container.support() |
| 38 | global.share = container.share |
| 39 | |
| 40 | if (config.noGlobals) return; |
| 41 | |
| 42 | output.print(output.styles.debug('Global functions are deprecated. Use `import { Helper, within, session } from "codeceptjs"` instead. Set `noGlobals: true` in config to disable globals.')); |
| 43 | |
| 44 | const HelperModule = await import('@codeceptjs/helper') |
| 45 | global.Helper = global.codecept_helper = HelperModule.default || HelperModule |
| 46 | |
| 47 | // Set up actor global - will use container when available |
| 48 | global.actor = global.codecept_actor = (obj) => { |
| 49 | return ActorFactory(obj, container) |
| 50 | } |
| 51 | global.Actor = global.actor |
| 52 | |
| 53 | global.within = async (...args) => { |
| 54 | return (await import('./effects.js')).within(...args) |
| 55 | } |
| 56 | |
| 57 | global.session = async (...args) => { |
| 58 | const sessionModule = await import('./session.js') |
| 59 | return (sessionModule.default || sessionModule)(...args) |
| 60 | } |
| 61 | |
| 62 | const dataTableModule = await import('./data/table.js') |
| 63 | global.DataTable = dataTableModule.default || dataTableModule |
| 64 | |
| 65 | global.locate = locatorQuery => { |
| 66 | return locator.build(locatorQuery) |
| 67 | } |
| 68 | |
| 69 | const secretModule = await import('./secret.js') |
| 70 | global.secret = secretModule.secret || (secretModule.default && secretModule.default.secret) |
| 71 | |
| 72 | const codeceptjsModule = await import('./index.js') // load all objects |
| 73 | global.codeceptjs = codeceptjsModule.default || codeceptjsModule |
| 74 |
no test coverage detected