codeceptjs 3.5.9-beta.1 → 3.5.9-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/build/Appium.js +6 -6
- package/docs/build/Playwright.js +63 -1
- package/docs/helpers/Appium.md +1 -1
- package/docs/helpers/Playwright.md +341 -303
- package/docs/internal-api.md +111 -0
- package/docs/plugins.md +4 -2
- package/lib/command/run-multiple.js +1 -1
- package/lib/command/run-workers.js +30 -4
- package/lib/command/workers/runTests.js +23 -0
- package/lib/event.js +2 -0
- package/lib/helper/Appium.js +10 -10
- package/lib/helper/Playwright.js +76 -5
- package/lib/helper/Puppeteer.js +7 -3
- package/lib/helper/WebDriver.js +6 -2
- package/lib/interfaces/gherkin.js +8 -1
- package/lib/interfaces/scenarioConfig.js +1 -0
- package/lib/locator.js +2 -2
- package/lib/plugin/autoLogin.js +4 -2
- package/lib/plugin/retryFailedStep.js +5 -0
- package/lib/plugin/stepByStepReport.js +2 -2
- package/lib/ui.js +1 -0
- package/lib/workers.js +2 -0
- package/package.json +4 -4
- package/typings/promiseBasedTypes.d.ts +31 -1
- package/typings/types.d.ts +34 -1
package/docs/build/Appium.js
CHANGED
|
@@ -368,7 +368,7 @@ class Appium extends Webdriver {
|
|
|
368
368
|
if (context.web) return this.switchToWeb(context.web);
|
|
369
369
|
if (context.webview) return this.switchToWeb(context.webview);
|
|
370
370
|
}
|
|
371
|
-
return this.
|
|
371
|
+
return this.switchToContext(context);
|
|
372
372
|
}
|
|
373
373
|
|
|
374
374
|
_withinEnd() {
|
|
@@ -834,7 +834,7 @@ class Appium extends Webdriver {
|
|
|
834
834
|
*
|
|
835
835
|
* @param {*} context the context to switch to
|
|
836
836
|
*/
|
|
837
|
-
async
|
|
837
|
+
async switchToContext(context) {
|
|
838
838
|
return this.browser.switchContext(context);
|
|
839
839
|
}
|
|
840
840
|
|
|
@@ -858,11 +858,11 @@ class Appium extends Webdriver {
|
|
|
858
858
|
this.isWeb = true;
|
|
859
859
|
this.defaultContext = 'body';
|
|
860
860
|
|
|
861
|
-
if (context) return this.
|
|
861
|
+
if (context) return this.switchToContext(context);
|
|
862
862
|
const contexts = await this.grabAllContexts();
|
|
863
863
|
this.debugSection('Contexts', contexts.toString());
|
|
864
864
|
for (const idx in contexts) {
|
|
865
|
-
if (contexts[idx].match(/^WEBVIEW/)) return this.
|
|
865
|
+
if (contexts[idx].match(/^WEBVIEW/)) return this.switchToContext(contexts[idx]);
|
|
866
866
|
}
|
|
867
867
|
|
|
868
868
|
throw new Error('No WEBVIEW could be guessed, please specify one in params');
|
|
@@ -885,8 +885,8 @@ class Appium extends Webdriver {
|
|
|
885
885
|
this.isWeb = false;
|
|
886
886
|
this.defaultContext = '//*';
|
|
887
887
|
|
|
888
|
-
if (context) return this.
|
|
889
|
-
return this.
|
|
888
|
+
if (context) return this.switchToContext(context);
|
|
889
|
+
return this.switchToContext('NATIVE_APP');
|
|
890
890
|
}
|
|
891
891
|
|
|
892
892
|
/**
|
package/docs/build/Playwright.js
CHANGED
|
@@ -94,6 +94,7 @@ const pathSeparator = path.sep;
|
|
|
94
94
|
* @prop {boolean} [ignoreHTTPSErrors] - Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
|
|
95
95
|
* @prop {boolean} [bypassCSP] - bypass Content Security Policy or CSP
|
|
96
96
|
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
97
|
+
* @prop {object} [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
|
|
97
98
|
*/
|
|
98
99
|
const config = {};
|
|
99
100
|
|
|
@@ -141,6 +142,21 @@ const config = {};
|
|
|
141
142
|
* * `trace`: enables trace recording for failed tests; trace are saved into `output/trace` folder
|
|
142
143
|
* * `keepTraceForPassedTests`: - save trace for passed tests
|
|
143
144
|
*
|
|
145
|
+
* #### HAR Recording Customization
|
|
146
|
+
*
|
|
147
|
+
* A HAR file is an HTTP Archive file that contains a record of all the network requests that are made when a page is loaded.
|
|
148
|
+
* It contains information about the request and response headers, cookies, content, timings, and more. You can use HAR files to mock network requests in your tests.
|
|
149
|
+
* HAR will be saved to `output/har`. More info could be found here https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har.
|
|
150
|
+
*
|
|
151
|
+
* ```
|
|
152
|
+
* ...
|
|
153
|
+
* recordHar: {
|
|
154
|
+
* mode: 'minimal', // possible values: 'minimal'|'full'.
|
|
155
|
+
* content: 'embed' // possible values: "omit"|"embed"|"attach".
|
|
156
|
+
* }
|
|
157
|
+
* ...
|
|
158
|
+
*```
|
|
159
|
+
*
|
|
144
160
|
* #### Example #1: Wait for 0 network connections.
|
|
145
161
|
*
|
|
146
162
|
* ```js
|
|
@@ -455,7 +471,8 @@ class Playwright extends Helper {
|
|
|
455
471
|
}
|
|
456
472
|
}
|
|
457
473
|
|
|
458
|
-
async _before() {
|
|
474
|
+
async _before(test) {
|
|
475
|
+
this.currentRunningTest = test;
|
|
459
476
|
recorder.retry({
|
|
460
477
|
retries: 5,
|
|
461
478
|
when: err => {
|
|
@@ -487,6 +504,15 @@ class Playwright extends Helper {
|
|
|
487
504
|
}
|
|
488
505
|
if (this.options.bypassCSP) contextOptions.bypassCSP = this.options.bypassCSP;
|
|
489
506
|
if (this.options.recordVideo) contextOptions.recordVideo = this.options.recordVideo;
|
|
507
|
+
if (this.options.recordHar) {
|
|
508
|
+
const harExt = this.options.recordHar.content && this.options.recordHar.content === 'attach' ? 'zip' : 'har';
|
|
509
|
+
const fileName = `${`${global.output_dir}${path.sep}har${path.sep}${uuidv4()}_${clearString(this.currentRunningTest.title)}`.slice(0, 245)}.${harExt}`;
|
|
510
|
+
const dir = path.dirname(fileName);
|
|
511
|
+
if (!fileExists(dir)) fs.mkdirSync(dir);
|
|
512
|
+
this.options.recordHar.path = fileName;
|
|
513
|
+
this.currentRunningTest.artifacts.har = fileName;
|
|
514
|
+
contextOptions.recordHar = this.options.recordHar;
|
|
515
|
+
}
|
|
490
516
|
if (this.storageState) contextOptions.storageState = this.storageState;
|
|
491
517
|
if (this.options.userAgent) contextOptions.userAgent = this.options.userAgent;
|
|
492
518
|
if (this.options.locale) contextOptions.locale = this.options.locale;
|
|
@@ -842,6 +868,7 @@ class Playwright extends Helper {
|
|
|
842
868
|
this.context = null;
|
|
843
869
|
this.frame = null;
|
|
844
870
|
popupStore.clear();
|
|
871
|
+
if (this.options.recordHar) await this.browserContext.close();
|
|
845
872
|
await this.browser.close();
|
|
846
873
|
}
|
|
847
874
|
|
|
@@ -1172,6 +1199,33 @@ class Playwright extends Helper {
|
|
|
1172
1199
|
return this.page.reload({ timeout: this.options.getPageTimeout, waitUntil: this.options.waitForNavigation });
|
|
1173
1200
|
}
|
|
1174
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* Replaying from HAR
|
|
1204
|
+
*
|
|
1205
|
+
* ```js
|
|
1206
|
+
* // Replay API requests from HAR.
|
|
1207
|
+
* // Either use a matching response from the HAR,
|
|
1208
|
+
* // or abort the request if nothing matches.
|
|
1209
|
+
* I.replayFromHar('./output/har/something.har', { url: "*\/**\/api/v1/fruits" });
|
|
1210
|
+
* I.amOnPage('https://demo.playwright.dev/api-mocking');
|
|
1211
|
+
* I.see('CodeceptJS');
|
|
1212
|
+
* ```
|
|
1213
|
+
*
|
|
1214
|
+
* @param {string} harFilePath Path to recorded HAR file
|
|
1215
|
+
* @param {object} [opts] [Options for replaying from HAR](https://playwright.dev/docs/api/class-page#page-route-from-har)
|
|
1216
|
+
*
|
|
1217
|
+
* @returns Promise<void>
|
|
1218
|
+
*/
|
|
1219
|
+
async replayFromHar(harFilePath, opts) {
|
|
1220
|
+
const file = path.join(global.codecept_dir, harFilePath);
|
|
1221
|
+
|
|
1222
|
+
if (!fileExists(file)) {
|
|
1223
|
+
throw new Error(`File at ${file} cannot be found on local system`);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
await this.page.routeFromHAR(harFilePath, opts);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1175
1229
|
/**
|
|
1176
1230
|
* Scroll page to the top.
|
|
1177
1231
|
*
|
|
@@ -3083,6 +3137,10 @@ class Playwright extends Helper {
|
|
|
3083
3137
|
test.artifacts[`trace_${sessionName}`] = await saveTraceForContext(this.sessionPages[sessionName].context, `${test.title}_${sessionName}.failed`);
|
|
3084
3138
|
}
|
|
3085
3139
|
}
|
|
3140
|
+
|
|
3141
|
+
if (this.options.recordHar) {
|
|
3142
|
+
test.artifacts.har = this.currentRunningTest.artifacts.har;
|
|
3143
|
+
}
|
|
3086
3144
|
}
|
|
3087
3145
|
|
|
3088
3146
|
async _passed(test) {
|
|
@@ -3110,6 +3168,10 @@ class Playwright extends Helper {
|
|
|
3110
3168
|
await this.browserContext.tracing.stop();
|
|
3111
3169
|
}
|
|
3112
3170
|
}
|
|
3171
|
+
|
|
3172
|
+
if (this.options.recordHar) {
|
|
3173
|
+
test.artifacts.har = this.currentRunningTest.artifacts.har;
|
|
3174
|
+
}
|
|
3113
3175
|
}
|
|
3114
3176
|
|
|
3115
3177
|
/**
|
package/docs/helpers/Appium.md
CHANGED