@taqwright/taqwright 0.0.24
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/LICENSE +201 -0
- package/README.md +108 -0
- package/dist/auto-appium.d.ts +12 -0
- package/dist/auto-appium.js +77 -0
- package/dist/bin/branding.d.ts +6 -0
- package/dist/bin/branding.js +22 -0
- package/dist/bin/index.d.ts +2 -0
- package/dist/bin/index.js +321 -0
- package/dist/bin/init.d.ts +26 -0
- package/dist/bin/init.js +902 -0
- package/dist/bin/inspect.d.ts +9 -0
- package/dist/bin/inspect.js +91 -0
- package/dist/bin/report-branding.d.ts +2 -0
- package/dist/bin/report-branding.js +42 -0
- package/dist/branding-assets.d.ts +1 -0
- package/dist/branding-assets.js +1 -0
- package/dist/capabilities-helpers.d.ts +7 -0
- package/dist/capabilities-helpers.js +14 -0
- package/dist/capabilities.d.ts +6 -0
- package/dist/capabilities.js +86 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +235 -0
- package/dist/discovery-setup.d.ts +1 -0
- package/dist/discovery-setup.js +61 -0
- package/dist/discovery.d.ts +17 -0
- package/dist/discovery.js +55 -0
- package/dist/docs/configuration.html +376 -0
- package/dist/docs/custom-reporters.html +265 -0
- package/dist/docs/docker.html +339 -0
- package/dist/docs/docs.js +173 -0
- package/dist/docs/generating-tests.html +161 -0
- package/dist/docs/images/taqwright-html-report.png +0 -0
- package/dist/docs/index.html +13 -0
- package/dist/docs/installation.html +686 -0
- package/dist/docs/parallel.html +271 -0
- package/dist/docs/running-tests.html +385 -0
- package/dist/docs/styles.css +460 -0
- package/dist/docs/writing-tests.html +565 -0
- package/dist/doctor.d.ts +33 -0
- package/dist/doctor.js +508 -0
- package/dist/expect.d.ts +38 -0
- package/dist/expect.js +96 -0
- package/dist/fixture/artifact-mode.d.ts +2 -0
- package/dist/fixture/artifact-mode.js +7 -0
- package/dist/fixture/index.d.ts +15 -0
- package/dist/fixture/index.js +324 -0
- package/dist/images/taqwright-html-report.png +0 -0
- package/dist/images/taqwright_favicon.png +0 -0
- package/dist/images/taqwright_logo.png +0 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/inspector/codegen-appium.d.ts +3 -0
- package/dist/inspector/codegen-appium.js +228 -0
- package/dist/inspector/devices.d.ts +41 -0
- package/dist/inspector/devices.js +422 -0
- package/dist/inspector/locator-suggester.d.ts +23 -0
- package/dist/inspector/locator-suggester.js +539 -0
- package/dist/inspector/recorder.d.ts +128 -0
- package/dist/inspector/recorder.js +162 -0
- package/dist/inspector/server.d.ts +39 -0
- package/dist/inspector/server.js +1210 -0
- package/dist/inspector/session.d.ts +84 -0
- package/dist/inspector/session.js +262 -0
- package/dist/inspector/ui.d.ts +1 -0
- package/dist/inspector/ui.js +5508 -0
- package/dist/keys.d.ts +3 -0
- package/dist/keys.js +28 -0
- package/dist/locator/index.d.ts +206 -0
- package/dist/locator/index.js +1506 -0
- package/dist/logger.d.ts +5 -0
- package/dist/logger.js +5 -0
- package/dist/mobile/index.d.ts +130 -0
- package/dist/mobile/index.js +762 -0
- package/dist/network/android.d.ts +5 -0
- package/dist/network/android.js +87 -0
- package/dist/network/ca.d.ts +10 -0
- package/dist/network/ca.js +136 -0
- package/dist/network/har.d.ts +90 -0
- package/dist/network/har.js +101 -0
- package/dist/network/host-proxy.d.ts +16 -0
- package/dist/network/host-proxy.js +134 -0
- package/dist/network/index.d.ts +26 -0
- package/dist/network/index.js +105 -0
- package/dist/network/ios-sim.d.ts +3 -0
- package/dist/network/ios-sim.js +29 -0
- package/dist/network/proxy.d.ts +13 -0
- package/dist/network/proxy.js +310 -0
- package/dist/providers/appium.d.ts +23 -0
- package/dist/providers/appium.js +288 -0
- package/dist/providers/browserstack/index.d.ts +5 -0
- package/dist/providers/browserstack/index.js +77 -0
- package/dist/providers/browserstack/utils.d.ts +1 -0
- package/dist/providers/browserstack/utils.js +6 -0
- package/dist/providers/cloud.d.ts +53 -0
- package/dist/providers/cloud.js +117 -0
- package/dist/providers/emulator/index.d.ts +8 -0
- package/dist/providers/emulator/index.js +47 -0
- package/dist/providers/index.d.ts +10 -0
- package/dist/providers/index.js +33 -0
- package/dist/providers/lambdatest/index.d.ts +28 -0
- package/dist/providers/lambdatest/index.js +99 -0
- package/dist/providers/lambdatest/utils.d.ts +1 -0
- package/dist/providers/lambdatest/utils.js +6 -0
- package/dist/providers/local/index.d.ts +9 -0
- package/dist/providers/local/index.js +53 -0
- package/dist/providers/local-session.d.ts +16 -0
- package/dist/providers/local-session.js +55 -0
- package/dist/setup/archive.d.ts +2 -0
- package/dist/setup/archive.js +43 -0
- package/dist/setup/avd.d.ts +12 -0
- package/dist/setup/avd.js +103 -0
- package/dist/setup/index.d.ts +6 -0
- package/dist/setup/index.js +55 -0
- package/dist/setup/install-android.d.ts +2 -0
- package/dist/setup/install-android.js +70 -0
- package/dist/setup/install-appium.d.ts +1 -0
- package/dist/setup/install-appium.js +64 -0
- package/dist/setup/install-jdk.d.ts +1 -0
- package/dist/setup/install-jdk.js +58 -0
- package/dist/setup/paths.d.ts +16 -0
- package/dist/setup/paths.js +88 -0
- package/dist/setup/spawn-tool.d.ts +3 -0
- package/dist/setup/spawn-tool.js +11 -0
- package/dist/tracer/index.d.ts +34 -0
- package/dist/tracer/index.js +687 -0
- package/dist/tracer/proxy.d.ts +3 -0
- package/dist/tracer/proxy.js +60 -0
- package/dist/types/index.d.ts +189 -0
- package/dist/types/index.js +6 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +37 -0
- package/package.json +79 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export class Recorder {
|
|
2
|
+
actions = [];
|
|
3
|
+
push(a) {
|
|
4
|
+
this.actions.push(a);
|
|
5
|
+
}
|
|
6
|
+
list() {
|
|
7
|
+
return [...this.actions];
|
|
8
|
+
}
|
|
9
|
+
clear() {
|
|
10
|
+
this.actions.length = 0;
|
|
11
|
+
}
|
|
12
|
+
toSpec(testName = 'recorded test') {
|
|
13
|
+
const lines = [
|
|
14
|
+
`import { test, expect } from '@taqwright/taqwright';`,
|
|
15
|
+
``,
|
|
16
|
+
`test(${jsString(testName)}, async ({ mobile }) => {`,
|
|
17
|
+
];
|
|
18
|
+
if (this.actions.length === 0) {
|
|
19
|
+
lines.push(` // (no actions recorded yet — interact with the device in the inspector)`);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
for (const a of this.actions) {
|
|
23
|
+
lines.push(' ' + renderAction(a));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
lines.push(`});`, ``);
|
|
27
|
+
return lines.join('\n');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function renderAction(a) {
|
|
31
|
+
switch (a.kind) {
|
|
32
|
+
case 'tap':
|
|
33
|
+
return `await mobile.click({ x: ${a.x}, y: ${a.y} });`;
|
|
34
|
+
case 'swipe':
|
|
35
|
+
return (`await mobile.raw.performActions([{ type: 'pointer', id: 'finger1', ` +
|
|
36
|
+
`parameters: { pointerType: 'touch' }, actions: [` +
|
|
37
|
+
`{ type: 'pointerMove', duration: 0, x: ${a.x1}, y: ${a.y1} }, ` +
|
|
38
|
+
`{ type: 'pointerDown', button: 0 }, ` +
|
|
39
|
+
`{ type: 'pointerMove', duration: ${a.durationMs}, x: ${a.x2}, y: ${a.y2} }, ` +
|
|
40
|
+
`{ type: 'pointerUp', button: 0 }] }]);`);
|
|
41
|
+
case 'sendKeys':
|
|
42
|
+
return `await mobile.raw.execute('mobile: type', [{ text: ${jsString(a.text)} }]);`;
|
|
43
|
+
case 'switchContext':
|
|
44
|
+
return /^NATIVE_APP$/i.test(a.context)
|
|
45
|
+
? `await mobile.switchToNative();`
|
|
46
|
+
: `await mobile.switchToWebView();`;
|
|
47
|
+
case 'screenScroll': {
|
|
48
|
+
const fn = a.direction === 'left' || a.direction === 'right' ? 'swipe' : 'scroll';
|
|
49
|
+
const fromParts = [];
|
|
50
|
+
if (a.fromX !== undefined)
|
|
51
|
+
fromParts.push(`x: ${trimNum(a.fromX)}`);
|
|
52
|
+
if (a.fromY !== undefined)
|
|
53
|
+
fromParts.push(`y: ${trimNum(a.fromY)}`);
|
|
54
|
+
const toParts = [];
|
|
55
|
+
if (a.toX !== undefined)
|
|
56
|
+
toParts.push(`x: ${trimNum(a.toX)}`);
|
|
57
|
+
if (a.toY !== undefined)
|
|
58
|
+
toParts.push(`y: ${trimNum(a.toY)}`);
|
|
59
|
+
if (fromParts.length === 0 && toParts.length === 0) {
|
|
60
|
+
return `await mobile.${fn}(${jsString(a.direction)});`;
|
|
61
|
+
}
|
|
62
|
+
const optsParts = [];
|
|
63
|
+
if (fromParts.length)
|
|
64
|
+
optsParts.push(`from: { ${fromParts.join(', ')} }`);
|
|
65
|
+
if (toParts.length)
|
|
66
|
+
optsParts.push(`to: { ${toParts.join(', ')} }`);
|
|
67
|
+
return `await mobile.${fn}(${jsString(a.direction)}, { ${optsParts.join(', ')} });`;
|
|
68
|
+
}
|
|
69
|
+
case 'locatorClick':
|
|
70
|
+
return `await ${a.code}.click();`;
|
|
71
|
+
case 'locatorDoubleTap':
|
|
72
|
+
return `await ${a.code}.doubleTap();`;
|
|
73
|
+
case 'locatorLongPress':
|
|
74
|
+
return `await ${a.code}.longPress();`;
|
|
75
|
+
case 'locatorFill':
|
|
76
|
+
return `await ${a.code}.fill(${jsString(a.text)});`;
|
|
77
|
+
case 'locatorClear':
|
|
78
|
+
return `await ${a.code}.clear();`;
|
|
79
|
+
case 'assertVisible':
|
|
80
|
+
return `await expect(${a.code}).toBeVisible();`;
|
|
81
|
+
case 'assertHidden':
|
|
82
|
+
return `await expect(${a.code}).toBeHidden();`;
|
|
83
|
+
case 'assertEnabled':
|
|
84
|
+
return `await expect(${a.code}).toBeEnabled();`;
|
|
85
|
+
case 'assertDisabled':
|
|
86
|
+
return `await expect(${a.code}).toBeDisabled();`;
|
|
87
|
+
case 'assertText':
|
|
88
|
+
return a.mode === 'contains'
|
|
89
|
+
? `await expect(${a.code}).toContainText(${jsString(a.expected)});`
|
|
90
|
+
: `await expect(${a.code}).toHaveText(${jsString(a.expected)});`;
|
|
91
|
+
case 'assertValue':
|
|
92
|
+
return `await expect(${a.code}).toHaveValue(${jsString(a.expected)});`;
|
|
93
|
+
case 'locatorSwipe': {
|
|
94
|
+
const m = 'swipe' + a.direction[0].toUpperCase() + a.direction.slice(1);
|
|
95
|
+
return `await ${a.code}.${m}();`;
|
|
96
|
+
}
|
|
97
|
+
case 'locatorScrollIntoView':
|
|
98
|
+
return `await ${a.code}.scrollIntoView();`;
|
|
99
|
+
case 'locatorPinch':
|
|
100
|
+
return `await ${a.code}.pinch${a.direction === 'in' ? 'In' : 'Out'}();`;
|
|
101
|
+
case 'locatorDragTo':
|
|
102
|
+
return `await ${a.code}.dragTo(${a.targetCode});`;
|
|
103
|
+
case 'locatorCheck':
|
|
104
|
+
return `await ${a.code}.check();`;
|
|
105
|
+
case 'locatorUncheck':
|
|
106
|
+
return `await ${a.code}.uncheck();`;
|
|
107
|
+
case 'locatorFocus':
|
|
108
|
+
return `await ${a.code}.focus();`;
|
|
109
|
+
case 'locatorBlur':
|
|
110
|
+
return `await ${a.code}.blur();`;
|
|
111
|
+
case 'assertChecked':
|
|
112
|
+
return `await expect(${a.code}).toBeChecked();`;
|
|
113
|
+
case 'assertUnchecked':
|
|
114
|
+
return `await expect(${a.code}).not.toBeChecked();`;
|
|
115
|
+
case 'locatorPress':
|
|
116
|
+
return `await ${a.code}.press(${jsString(a.key)});`;
|
|
117
|
+
case 'locatorPressSequentially':
|
|
118
|
+
return a.delay
|
|
119
|
+
? `await ${a.code}.pressSequentially(${jsString(a.text)}, { delay: ${a.delay} });`
|
|
120
|
+
: `await ${a.code}.pressSequentially(${jsString(a.text)});`;
|
|
121
|
+
case 'locatorSelectOption':
|
|
122
|
+
return `await ${a.code}.selectOption(${formatSelectOptionInput(a.value)});`;
|
|
123
|
+
case 'assertEditable':
|
|
124
|
+
return `await expect(${a.code}).toBeEditable();`;
|
|
125
|
+
case 'assertReadonly':
|
|
126
|
+
return `await expect(${a.code}).not.toBeEditable();`;
|
|
127
|
+
case 'assertFocused':
|
|
128
|
+
return `await expect(${a.code}).toBeFocused();`;
|
|
129
|
+
case 'assertAttached':
|
|
130
|
+
return `await expect(${a.code}).toBeAttached();`;
|
|
131
|
+
case 'assertEmpty':
|
|
132
|
+
return `await expect(${a.code}).toBeEmpty();`;
|
|
133
|
+
case 'assertInViewport':
|
|
134
|
+
return `await expect(${a.code}).toBeInViewport();`;
|
|
135
|
+
case 'assertCount':
|
|
136
|
+
return `await expect(${a.code}).toHaveCount(${a.expected});`;
|
|
137
|
+
case 'assertAttribute':
|
|
138
|
+
return `await expect(${a.code}).toHaveAttribute(${jsString(a.name)}, ${jsString(a.expected)});`;
|
|
139
|
+
case 'comment':
|
|
140
|
+
return `// ${a.text}`;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function formatSelectOptionInput(v) {
|
|
144
|
+
if (typeof v === 'string')
|
|
145
|
+
return jsString(v);
|
|
146
|
+
const parts = [];
|
|
147
|
+
if (v.label !== undefined)
|
|
148
|
+
parts.push(`label: ${jsString(v.label)}`);
|
|
149
|
+
if (v.index !== undefined)
|
|
150
|
+
parts.push(`index: ${v.index}`);
|
|
151
|
+
if (v.date !== undefined)
|
|
152
|
+
parts.push(`date: ${jsString(v.date)}`);
|
|
153
|
+
if (v.time !== undefined)
|
|
154
|
+
parts.push(`time: ${jsString(v.time)}`);
|
|
155
|
+
return `{ ${parts.join(', ')} }`;
|
|
156
|
+
}
|
|
157
|
+
function jsString(s) {
|
|
158
|
+
return JSON.stringify(s);
|
|
159
|
+
}
|
|
160
|
+
function trimNum(n) {
|
|
161
|
+
return Number.isInteger(n) ? n.toFixed(0) : Number(n.toFixed(3)).toString();
|
|
162
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type IncomingMessage } from 'node:http';
|
|
2
|
+
import type { Client as WebDriverClient } from 'webdriver';
|
|
3
|
+
import { Platform, type LocatorDescriptor } from '../types/index.js';
|
|
4
|
+
import { InspectorSession, type InspectorDefaults } from './session.js';
|
|
5
|
+
export interface InspectorServerOptions {
|
|
6
|
+
defaults: InspectorDefaults;
|
|
7
|
+
port: number;
|
|
8
|
+
host: string;
|
|
9
|
+
attach?: {
|
|
10
|
+
driver: WebDriverClient;
|
|
11
|
+
platform: Platform;
|
|
12
|
+
capabilities?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface InspectorServerHandle {
|
|
16
|
+
url: string;
|
|
17
|
+
port: number;
|
|
18
|
+
session: InspectorSession;
|
|
19
|
+
close: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export declare function startInspectorServer(opts: InspectorServerOptions): Promise<InspectorServerHandle>;
|
|
22
|
+
type LocatorTarget = {
|
|
23
|
+
code: string;
|
|
24
|
+
descriptor?: LocatorDescriptor;
|
|
25
|
+
using?: string;
|
|
26
|
+
value?: string;
|
|
27
|
+
};
|
|
28
|
+
export declare function resolveLocatorDescriptor(body: LocatorTarget): LocatorDescriptor;
|
|
29
|
+
export declare function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T>;
|
|
30
|
+
export declare function readJson<T>(req: IncomingMessage): Promise<T>;
|
|
31
|
+
export interface CloudDevice {
|
|
32
|
+
provider: 'browserstack' | 'lambdatest';
|
|
33
|
+
platform: 'android' | 'ios';
|
|
34
|
+
deviceName: string;
|
|
35
|
+
osVersion: string;
|
|
36
|
+
realDevice: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function parseLambdatestDevices(raw: unknown): CloudDevice[];
|
|
39
|
+
export {};
|