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

Method prepareBrowsers

lib/command/run-multiple/collection.js:116–150  ·  view source on GitHub ↗

* Expands browser declared via `browsers` property to multiple * runs that all have one single `browser` property and omits * the `browsers` property. *

(config)

Source from the content-addressed store, hash-verified

114 * the `browsers` property.
115 * */
116 prepareBrowsers(config) {
117 this.runs.forEach((run) => {
118 const runName = run.getName();
119 const runConfig = run.getConfig();
120 const browsers = [];
121
122 if (!Array.isArray(runConfig.browsers)) {
123 runConfig.browsers = guessBrowser(config) || [];
124 }
125
126 // no browser property in helper?
127 if (!runConfig.browsers.length) {
128 runConfig.browsers.push('default');
129 }
130
131 runConfig.browsers.forEach((browser) => {
132 const browserConfig = browser.browser ? browser : { browser };
133 const runBrowserConfig = { ...runConfig, browser: browserConfig };
134 browsers.push(browserConfig.browser);
135 const count = browsers.filter((b) => {
136 return b === browserConfig.browser;
137 }).length;
138
139 delete runBrowserConfig.browsers;
140
141 const run = createRun(`${runName}:${browserConfig.browser}${count}`, runBrowserConfig);
142 run.setOriginalName(runName);
143 this.addRun(run);
144 });
145
146 this.removeRun(runName);
147 });
148
149 return this;
150 }
151
152 /**
153 * Filters all runs by their `browser` property. The property `browsers` is ignored.

Callers 1

createRunsFunction · 0.80

Calls 9

addRunMethod · 0.95
removeRunMethod · 0.95
createRunFunction · 0.90
guessBrowserFunction · 0.85
getNameMethod · 0.80
pushMethod · 0.80
filterMethod · 0.80
setOriginalNameMethod · 0.80
getConfigMethod · 0.45

Tested by

no test coverage detected