(scenario, variantOrScenarioLabelSafe, scenarioLabelSafe, viewport, config, browser)
| 123 | }; |
| 124 | |
| 125 | async function processScenarioView (scenario, variantOrScenarioLabelSafe, scenarioLabelSafe, viewport, config, browser) { |
| 126 | const { engineOptions, scenarioDefaults = {} } = config; |
| 127 | |
| 128 | /** |
| 129 | * @type {Object} |
| 130 | * @description Spread `scenarioDefaults` into the scenario. |
| 131 | * @default `scenario` |
| 132 | */ |
| 133 | scenario = { |
| 134 | ...scenarioDefaults, |
| 135 | ...scenario |
| 136 | }; |
| 137 | |
| 138 | if (!config.paths) { |
| 139 | config.paths = {}; |
| 140 | } |
| 141 | |
| 142 | if (typeof viewport.label !== 'string') { |
| 143 | viewport.label = viewport.name || ''; |
| 144 | } |
| 145 | |
| 146 | const engineScriptsPath = config.env.engine_scripts || config.env.engine_scripts_default; |
| 147 | const isReference = config.isReference; |
| 148 | |
| 149 | const VP_W = viewport.width || viewport.viewport.width; |
| 150 | const VP_H = viewport.height || viewport.viewport.height; |
| 151 | |
| 152 | const ignoreHTTPSErrors = engineOptions.ignoreHTTPSErrors ? engineOptions.ignoreHTTPSErrors : true; |
| 153 | const storageState = engineOptions.storageState ? engineOptions.storageState : {}; |
| 154 | const browserContext = await browser.newContext({ ignoreHTTPSErrors, storageState }); |
| 155 | const page = await browserContext.newPage(); |
| 156 | |
| 157 | await page.setViewportSize({ width: VP_W, height: VP_H }); |
| 158 | page.setDefaultNavigationTimeout(engineTools.getEngineOption(config, 'waitTimeout', TEST_TIMEOUT)); |
| 159 | |
| 160 | if (isReference) { |
| 161 | console.log(chalk.blue('CREATING NEW REFERENCE FILE')); |
| 162 | } |
| 163 | |
| 164 | // --- set up console output and ready event --- |
| 165 | const readyEvent = scenario.readyEvent || config.readyEvent; |
| 166 | const readyTimeout = scenario.readyTimeout || config.readyTimeout || 30000; |
| 167 | let readyResolve, readyPromise, readyTimeoutTimer; |
| 168 | if (readyEvent) { |
| 169 | readyPromise = new Promise(resolve => { |
| 170 | readyResolve = resolve; |
| 171 | // fire the ready event after the readyTimeout |
| 172 | readyTimeoutTimer = setTimeout(() => { |
| 173 | console.error(chalk.red(`ReadyEvent not detected within readyTimeout limit. (${readyTimeout} ms)`), scenario.url); |
| 174 | resolve(); |
| 175 | }, readyTimeout); |
| 176 | }); |
| 177 | } |
| 178 | |
| 179 | page.on('console', msg => { |
| 180 | for (let i = 0; i < msg.args().length; ++i) { |
| 181 | const line = msg.args()[i]; |
| 182 | console.log(`Browser Console Log ${i}: ${line}`); |
no test coverage detected