MCPcopy
hub / github.com/codeceptjs/CodeceptJS / addConfig

Method addConfig

lib/workers.js:220–248  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

218 }
219
220 addConfig(config) {
221 const oldConfig = JSON.parse(this.options.override || '{}')
222
223 // Remove customLocatorStrategies from both old and new config before JSON serialization
224 // since functions cannot be serialized and will be lost, causing workers to have empty strategies.
225 // Note: Only WebDriver helper supports customLocatorStrategies
226 const configWithoutFunctions = { ...config }
227
228 // Clean both old and new config
229 const cleanConfig = cfg => {
230 if (cfg.helpers) {
231 cfg.helpers = { ...cfg.helpers }
232 Object.keys(cfg.helpers).forEach(helperName => {
233 if (cfg.helpers[helperName] && cfg.helpers[helperName].customLocatorStrategies !== undefined) {
234 cfg.helpers[helperName] = { ...cfg.helpers[helperName] }
235 delete cfg.helpers[helperName].customLocatorStrategies
236 }
237 })
238 }
239 return cfg
240 }
241
242 const cleanedOldConfig = cleanConfig(oldConfig)
243 const cleanedNewConfig = cleanConfig(configWithoutFunctions)
244
245 // Deep merge configurations to preserve all helpers from base config
246 const newConfig = merge({}, cleanedOldConfig, cleanedNewConfig)
247 this.options.override = JSON.stringify(newConfig)
248 }
249
250 addTestFiles(testGroup) {
251 this.addTests(convertToMochaTests(testGroup))

Callers 3

createWorkerObjectsFunction · 0.95
overrideConfigMethod · 0.80
worker_test.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected