@testchimp/playwright 0.2.4 → 0.2.5
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/README.md
CHANGED
|
@@ -84,7 +84,7 @@ export const test = installTestChimp(base); // default uiFixture: 'page'
|
|
|
84
84
|
|
|
85
85
|
A side-effect-only `import '@testchimp/playwright/runtime'` does not apply extended fixtures or mobile hooks; the returned `TestType` from `installTestChimp` must be what your specs import.
|
|
86
86
|
|
|
87
|
-
**Web:** the runtime injects `__TC_CI_TEST_INFO` on the `page` fixture for `@testchimp/rum-js`, then in **`afterEach`**
|
|
87
|
+
**Web:** the runtime injects `__TC_CI_TEST_INFO` on the `page` fixture for `@testchimp/rum-js`, then in **`afterEach`** awaits `globalThis.__TC_RUM_FLUSH()` (async in rum-js **≥ 0.1.6**) so the keepalive `POST /rum/events` finishes before the context closes. Requires `@testchimp/playwright` **≥ 0.2.5**. Optional: `TESTCHIMP_RUM_WEB_FLUSH_TIMEOUT_MS` (default **5000**, clamp **100–30000**).
|
|
88
88
|
|
|
89
89
|
**Mobile (iOS/Android):** set `use.platform` to `ios` or `android` on Mobilewright UI projects and use `installTestChimp(base, { uiFixture: 'screen' })`. The runtime extends the Mobilewright **`device`** fixture so **`SET`** runs right after Mobilewright’s **`launchApp`** (via `device.openUrl`), before **`screen`** and the test body; **`afterEach`** still sends a trailing **`SET`** + **`v1/flush`**. By default **no** `/v1/clear` between tests—each test **`SET`s** new CI so RUM avoids a clear→set gap with missing `ci_test_info`. Integrate **TestChimpRum** for that platform (see `testchimp-rum-ios` / `testchimp-rum-android` READMEs): URL scheme / intent filter for `testchimp-rum://truecoverage/...`.
|
|
90
90
|
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
/** Per-call cap for `page.evaluate` RUM flush so a wedged page does not burn the whole test timeout. */
|
|
2
2
|
export declare function resolveWebRumFlushTimeoutMs(): number;
|
|
3
3
|
type PageWithEvaluate = {
|
|
4
|
-
evaluate: (fn: () => void
|
|
5
|
-
waitForResponse: (predicate: (res: {
|
|
6
|
-
request: () => {
|
|
7
|
-
method: () => string;
|
|
8
|
-
};
|
|
9
|
-
url: () => string;
|
|
10
|
-
}) => boolean, options?: {
|
|
11
|
-
timeout?: number;
|
|
12
|
-
}) => Promise<unknown>;
|
|
4
|
+
evaluate: (fn: () => void | Promise<void>, arg?: unknown) => Promise<unknown>;
|
|
13
5
|
};
|
|
14
6
|
/**
|
|
15
7
|
* Flush buffered @testchimp/rum-js events before Playwright tears down the page.
|
|
16
|
-
*
|
|
8
|
+
* Awaits `globalThis.__TC_RUM_FLUSH` (rum-js ≥ 0.1.6) so keepalive POST completes in-page.
|
|
17
9
|
* Non-fatal when the page is closed, buffer is empty, or rum-js is not initialized.
|
|
18
10
|
*/
|
|
19
11
|
export declare function flushWebRumBuffer(page: PageWithEvaluate): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rum-automation-web.d.ts","sourceRoot":"","sources":["../src/rum-automation-web.ts"],"names":[],"mappings":"AAGA,wGAAwG;AACxG,wBAAgB,2BAA2B,IAAI,MAAM,CAMpD;AAgBD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"rum-automation-web.d.ts","sourceRoot":"","sources":["../src/rum-automation-web.ts"],"names":[],"mappings":"AAGA,wGAAwG;AACxG,wBAAgB,2BAA2B,IAAI,MAAM,CAMpD;AAgBD,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/E,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB7E;AAED;;;GAGG;AAEH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAa9D"}
|
|
@@ -31,25 +31,21 @@ async function withTimeout(promise, ms, operation) {
|
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Flush buffered @testchimp/rum-js events before Playwright tears down the page.
|
|
34
|
-
*
|
|
34
|
+
* Awaits `globalThis.__TC_RUM_FLUSH` (rum-js ≥ 0.1.6) so keepalive POST completes in-page.
|
|
35
35
|
* Non-fatal when the page is closed, buffer is empty, or rum-js is not initialized.
|
|
36
36
|
*/
|
|
37
37
|
async function flushWebRumBuffer(page) {
|
|
38
38
|
const timeoutMs = resolveWebRumFlushTimeoutMs();
|
|
39
39
|
try {
|
|
40
|
-
|
|
41
|
-
.waitForResponse((res) => res.request().method() === 'POST' && res.url().includes('/rum/events'), { timeout: timeoutMs })
|
|
42
|
-
.catch(() => undefined);
|
|
43
|
-
await withTimeout(page.evaluate(() => {
|
|
40
|
+
await withTimeout(page.evaluate(async () => {
|
|
44
41
|
const g = globalThis;
|
|
45
42
|
if (typeof g.__TC_RUM_FLUSH === 'function') {
|
|
46
|
-
g.__TC_RUM_FLUSH();
|
|
43
|
+
await g.__TC_RUM_FLUSH();
|
|
47
44
|
}
|
|
48
45
|
else if (typeof g.testchimp?.flush === 'function') {
|
|
49
46
|
g.testchimp.flush();
|
|
50
47
|
}
|
|
51
48
|
}), timeoutMs, 'flushWebRumBuffer');
|
|
52
|
-
await responseDone;
|
|
53
49
|
}
|
|
54
50
|
catch {
|
|
55
51
|
// Non-fatal: page closed, navigation torn down, or rum not initialized.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rum-automation-web.js","sourceRoot":"","sources":["../src/rum-automation-web.ts"],"names":[],"mappings":";;AAIA,kEAMC;
|
|
1
|
+
{"version":3,"file":"rum-automation-web.js","sourceRoot":"","sources":["../src/rum-automation-web.ts"],"names":[],"mappings":";;AAIA,kEAMC;AAyBD,8CAqBC;AAOD,kE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