@testchimp/playwright 0.1.29 → 0.1.31
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.
|
@@ -13,6 +13,10 @@ export declare function buildAutomationSetOpenUrl(setUrlPrefix: string, ciJson:
|
|
|
13
13
|
/**
|
|
14
14
|
* Register `beforeEach` / `afterEach` on the given Playwright `TestType` to push CI JSON into the app via
|
|
15
15
|
* `device.openUrl` (mobilecli `device.url`). Used when `TESTCHIMP_PROJECT_TYPE` is `ios`/`android`.
|
|
16
|
+
*
|
|
17
|
+
* Each test's `beforeEach` builds `ci_test_info` from **that** run's `testInfo`, optionally foregrounds the
|
|
18
|
+
* app with `device.launchApp(bundleId)` when both are available, then opens the set URL. `afterEach`
|
|
19
|
+
* clears automation context via the clear URL so the next test receives a fresh set payload.
|
|
16
20
|
*/
|
|
17
21
|
export declare function attachMobileRumAutomationHooks(testType: any): any;
|
|
18
22
|
//# sourceMappingURL=rum-automation-mobile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rum-automation-mobile.d.ts","sourceRoot":"","sources":["../src/rum-automation-mobile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rum-automation-mobile.d.ts","sourceRoot":"","sources":["../src/rum-automation-mobile.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAWD;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,uBAAuB,CAKpE;AAED,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAS1G;AA+BD;;;;;;;GAOG;AAEH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CA2CjE"}
|
|
@@ -8,6 +8,8 @@ const DEFAULT_SET_PREFIX = 'testchimp-rum://truecoverage/v1/set?p=';
|
|
|
8
8
|
const DEFAULT_CLEAR_URL = 'testchimp-rum://truecoverage/v1/clear';
|
|
9
9
|
/** Max length for the full openUrl string (conservative for iOS). */
|
|
10
10
|
const MAX_OPEN_URL_CHARS = 8000;
|
|
11
|
+
const SET_OPEN_URL_MAX_ATTEMPTS = 3;
|
|
12
|
+
const SET_OPEN_URL_RETRY_DELAY_MS = 400;
|
|
11
13
|
/**
|
|
12
14
|
* URL prefix and clear URL for Mobilewright TrueCoverage (`device.openUrl`).
|
|
13
15
|
* Optional overrides: `TESTCHIMP_RUM_AUTOMATION_SET_PREFIX`, `TESTCHIMP_RUM_AUTOMATION_CLEAR_URL`.
|
|
@@ -28,15 +30,51 @@ function buildAutomationSetOpenUrl(setUrlPrefix, ciJson) {
|
|
|
28
30
|
}
|
|
29
31
|
return url;
|
|
30
32
|
}
|
|
33
|
+
async function sleep(ms) {
|
|
34
|
+
await new Promise((r) => setTimeout(r, ms));
|
|
35
|
+
}
|
|
36
|
+
async function openUrlSetWithRetries(device, url) {
|
|
37
|
+
let lastErr;
|
|
38
|
+
for (let attempt = 0; attempt < SET_OPEN_URL_MAX_ATTEMPTS; attempt++) {
|
|
39
|
+
try {
|
|
40
|
+
await device.openUrl(url);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
lastErr = err;
|
|
45
|
+
if (attempt < SET_OPEN_URL_MAX_ATTEMPTS - 1) {
|
|
46
|
+
await sleep(SET_OPEN_URL_RETRY_DELAY_MS);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const msg = lastErr instanceof Error ? lastErr.message : String(lastErr);
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
52
|
+
console.warn(`[TestChimp] TrueCoverage device.openUrl(set) failed after ${SET_OPEN_URL_MAX_ATTEMPTS} attempts (non-fatal): ${msg}`);
|
|
53
|
+
}
|
|
31
54
|
let warnedMobileAutomationOnce = false;
|
|
32
55
|
/**
|
|
33
56
|
* Register `beforeEach` / `afterEach` on the given Playwright `TestType` to push CI JSON into the app via
|
|
34
57
|
* `device.openUrl` (mobilecli `device.url`). Used when `TESTCHIMP_PROJECT_TYPE` is `ios`/`android`.
|
|
58
|
+
*
|
|
59
|
+
* Each test's `beforeEach` builds `ci_test_info` from **that** run's `testInfo`, optionally foregrounds the
|
|
60
|
+
* app with `device.launchApp(bundleId)` when both are available, then opens the set URL. `afterEach`
|
|
61
|
+
* clears automation context via the clear URL so the next test receives a fresh set payload.
|
|
35
62
|
*/
|
|
36
63
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
64
|
function attachMobileRumAutomationHooks(testType) {
|
|
38
65
|
const { setUrlPrefix, clearUrl } = getMobileRumAutomationUrls();
|
|
39
|
-
testType.beforeEach(async ({ device }, testInfo) => {
|
|
66
|
+
testType.beforeEach(async ({ device, bundleId }, testInfo) => {
|
|
67
|
+
const bid = typeof bundleId === 'string' && bundleId.trim() !== '' ? bundleId.trim() : undefined;
|
|
68
|
+
if (bid != null && typeof device.launchApp === 'function') {
|
|
69
|
+
try {
|
|
70
|
+
await device.launchApp(bid);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.warn(`[TestChimp] TrueCoverage device.launchApp failed (non-fatal): ${msg}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
40
78
|
const project = testInfo.project;
|
|
41
79
|
const projectRootDir = project?.rootDir ?? process.cwd();
|
|
42
80
|
const ciJson = (0, ci_test_info_1.buildCiTestInfoJson)(testInfo, projectRootDir);
|
|
@@ -49,14 +87,7 @@ function attachMobileRumAutomationHooks(testType) {
|
|
|
49
87
|
}
|
|
50
88
|
return;
|
|
51
89
|
}
|
|
52
|
-
|
|
53
|
-
await device.openUrl(built);
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
57
|
-
// eslint-disable-next-line no-console
|
|
58
|
-
console.warn(`[TestChimp] TrueCoverage device.openUrl(set) failed (non-fatal): ${msg}`);
|
|
59
|
-
}
|
|
90
|
+
await openUrlSetWithRetries(device, built);
|
|
60
91
|
});
|
|
61
92
|
testType.afterEach(async ({ device }) => {
|
|
62
93
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rum-automation-mobile.js","sourceRoot":"","sources":["../src/rum-automation-mobile.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"rum-automation-mobile.js","sourceRoot":"","sources":["../src/rum-automation-mobile.ts"],"names":[],"mappings":";;AA6BA,gEAKC;AAED,8DASC;AAwCD,wEA2CC;AAhID,iDAAyE;AAEzE,MAAM,kBAAkB,GAAG,wCAAwC,CAAC;AACpE,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AAElE,qEAAqE;AACrE,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAgBxC;;;GAGG;AACH,SAAgB,0BAA0B;IACxC,OAAO;QACL,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mCAAmC,EAAE,IAAI,EAAE,IAAI,kBAAkB;QAC3F,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,IAAI,EAAE,IAAI,iBAAiB;KACtF,CAAC;AACJ,CAAC;AAED,SAAgB,yBAAyB,CAAC,YAAoB,EAAE,MAAc;IAC5E,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAClE,MAAM,GAAG,GAAG,GAAG,YAAY,GAAG,OAAO,EAAE,CAAC;IACxC,IAAI,GAAG,CAAC,MAAM,GAAG,kBAAkB,E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