@testmuai/playwright-bindings 0.1.52 → 0.1.53-beta.1
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
|
@@ -70,6 +70,7 @@ files never breaks consumers.
|
|
|
70
70
|
| `LT_USERNAME`, `LT_ACCESS_KEY` | LambdaTest credentials (enables ATMS + vision) |
|
|
71
71
|
| `TESTMU_SMART` | `1` enables vision/heal (validated at run() — requires LT creds) |
|
|
72
72
|
| `TESTMU_READ_SETTLE_MS` | Re-read budget for a recorded read whose answer differs from its expected answer (ms, default 15000, max 30000) |
|
|
73
|
+
| `SMARTUI_SERVER_ADDRESS` | SmartUI server `smartuiSnapshot` captures through (default `http://localhost:49152`, the server `npx smartui exec:start` runs). With no server answering, the snapshot is skipped; a SmartUI error is logged and never fails the step (v4) |
|
|
73
74
|
|
|
74
75
|
## Build
|
|
75
76
|
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import type { Page } from 'playwright';
|
|
2
|
-
type
|
|
3
|
-
|
|
2
|
+
type SdkUtils = {
|
|
3
|
+
isSmartUIRunning(): Promise<boolean>;
|
|
4
|
+
fetchDOMSerializer(): Promise<{
|
|
5
|
+
body: {
|
|
6
|
+
data: {
|
|
7
|
+
dom: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
postSnapshot(snapshot: {
|
|
12
|
+
dom: unknown;
|
|
13
|
+
url: string;
|
|
14
|
+
name: string;
|
|
15
|
+
options: Record<string, unknown>;
|
|
16
|
+
}, testType: string): Promise<{
|
|
17
|
+
body?: {
|
|
18
|
+
data?: {
|
|
19
|
+
warnings?: string[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export declare function _resolveSdkUtils(mod: unknown): SdkUtils;
|
|
4
25
|
/** Test hook: forget the cached session id. */
|
|
5
26
|
export declare function _resetSessionId(): void;
|
|
6
|
-
export declare function _isModuleNotFound(e: unknown): boolean;
|
|
7
27
|
export declare function smartuiSnapshot(page: Page, name: string, options?: Record<string, unknown>): Promise<void>;
|
|
8
28
|
export {};
|
|
9
29
|
//# sourceMappingURL=smartui.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartui.d.ts","sourceRoot":"","sources":["../../../src/v4/helpers/smartui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smartui.d.ts","sourceRoot":"","sources":["../../../src/v4/helpers/smartui.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAMvC,KAAK,QAAQ,GAAG;IACd,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,kBAAkB,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE;YAAE,IAAI,EAAE;gBAAE,GAAG,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;IACnE,YAAY,CACV,QAAQ,EAAE;QAAE,GAAG,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EACvF,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE;gBAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAC,CAAC;CAC3D,CAAC;AAGF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAIvD;AAoBD,+CAA+C;AAC/C,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACpC,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { config } from '../../config.js';
|
|
2
1
|
import { log } from '../../log.js';
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
// The driver's testType, which the SmartUI server records for the snapshot.
|
|
3
|
+
const TEST_TYPE = 'js-playwright-driver';
|
|
4
|
+
// exported for unit testing — pure function, no module side effects
|
|
5
|
+
export function _resolveSdkUtils(mod) {
|
|
6
|
+
// CJS in Node ESM can surface as either top-level named exports or .default
|
|
6
7
|
const m = mod;
|
|
7
|
-
|
|
8
|
-
return m.smartuiSnapshot;
|
|
9
|
-
if (typeof m?.default?.smartuiSnapshot === 'function')
|
|
10
|
-
return m.default.smartuiSnapshot;
|
|
11
|
-
return null;
|
|
8
|
+
return (typeof m?.isSmartUIRunning === 'function' ? m : m.default);
|
|
12
9
|
}
|
|
13
10
|
// The grid session's id, looked up once per process.
|
|
14
11
|
let ltSessionId;
|
|
@@ -31,43 +28,28 @@ async function sessionId(page) {
|
|
|
31
28
|
export function _resetSessionId() {
|
|
32
29
|
ltSessionId = undefined;
|
|
33
30
|
}
|
|
34
|
-
export function _isModuleNotFound(e) {
|
|
35
|
-
const code = e?.code;
|
|
36
|
-
return code === 'ERR_MODULE_NOT_FOUND' || code === 'MODULE_NOT_FOUND';
|
|
37
|
-
}
|
|
38
31
|
export async function smartuiSnapshot(page, name, options = {}) {
|
|
32
|
+
const utils = _resolveSdkUtils(await import('@lambdatest/sdk-utils'));
|
|
39
33
|
log.helper(`[smartui_snapshot] name=${name}`);
|
|
40
|
-
if (
|
|
41
|
-
log.helper(`[smartui_snapshot]
|
|
34
|
+
if (!(await utils.isSmartUIRunning())) {
|
|
35
|
+
log.helper(`[smartui_snapshot] no SmartUI server — skipping name=${name}`);
|
|
42
36
|
return;
|
|
43
37
|
}
|
|
44
|
-
let mod;
|
|
45
38
|
try {
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
// The session id links the snapshot to the session in the Automation
|
|
40
|
+
// dashboard; the Selenium SDK sends driver.session_id the same way.
|
|
41
|
+
if (!options['sessionId']) {
|
|
42
|
+
const id = await sessionId(page);
|
|
43
|
+
if (id)
|
|
44
|
+
options = { ...options, sessionId: id };
|
|
52
45
|
}
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const serializer = await utils.fetchDOMSerializer();
|
|
47
|
+
await page.evaluate(serializer.body.data.dom);
|
|
48
|
+
const dom = await page.evaluate('SmartUIDOM.serialize({})');
|
|
49
|
+
const { body } = await utils.postSnapshot({ dom, url: page.url(), name, options }, TEST_TYPE);
|
|
50
|
+
for (const warning of body?.data?.warnings ?? []) {
|
|
51
|
+
log.helper(`[smartui_snapshot] ${warning}`);
|
|
55
52
|
}
|
|
56
|
-
throw e;
|
|
57
|
-
}
|
|
58
|
-
const snapshotFn = _resolveSdkFn(mod);
|
|
59
|
-
if (!snapshotFn) {
|
|
60
|
-
throw new Error('[smartui_snapshot] SDK loaded but smartuiSnapshot export not found');
|
|
61
|
-
}
|
|
62
|
-
// The session id links the snapshot to the session in the Automation
|
|
63
|
-
// dashboard; the Selenium SDK sends driver.session_id the same way.
|
|
64
|
-
if (!options['sessionId']) {
|
|
65
|
-
const id = await sessionId(page);
|
|
66
|
-
if (id)
|
|
67
|
-
options = { ...options, sessionId: id };
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
await snapshotFn(page, name, options);
|
|
71
53
|
log.helper(`[smartui_snapshot] captured name=${name}`);
|
|
72
54
|
}
|
|
73
55
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartui.js","sourceRoot":"","sources":["../../../src/v4/helpers/smartui.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smartui.js","sourceRoot":"","sources":["../../../src/v4/helpers/smartui.ts"],"names":[],"mappings":"AASA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H,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testmuai/playwright-bindings",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.53-beta.1",
|
|
4
4
|
"description": "Testmu binding for Playwright — thin runtime for LambdaTest exports",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"playwright": ">=1.57.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
+
"@lambdatest/sdk-utils": "^1.0.8",
|
|
46
47
|
"ajv": "^8.17.1",
|
|
47
48
|
"aws4": "^1.13.2",
|
|
48
49
|
"dotenv": "^17.4.2",
|