@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,58 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, rmSync, statSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { jdkDir, downloadCacheDir } from './paths.js';
|
|
4
|
+
import { download, extract } from './archive.js';
|
|
5
|
+
function osArch() {
|
|
6
|
+
const osName = process.platform === 'darwin' ? 'mac' : process.platform === 'win32' ? 'windows' : 'linux';
|
|
7
|
+
const arch = process.arch === 'arm64' ? 'aarch64' : 'x64';
|
|
8
|
+
return { osName, arch };
|
|
9
|
+
}
|
|
10
|
+
function findJavaHome(root) {
|
|
11
|
+
const java = process.platform === 'win32' ? 'java.exe' : 'java';
|
|
12
|
+
const stack = [root];
|
|
13
|
+
while (stack.length) {
|
|
14
|
+
const dir = stack.pop();
|
|
15
|
+
if (existsSync(path.join(dir, 'bin', java)))
|
|
16
|
+
return dir;
|
|
17
|
+
let entries;
|
|
18
|
+
try {
|
|
19
|
+
entries = readdirSync(dir);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
for (const e of entries) {
|
|
25
|
+
const full = path.join(dir, e);
|
|
26
|
+
try {
|
|
27
|
+
if (statSync(full).isDirectory())
|
|
28
|
+
stack.push(full);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
export async function installJdk(force) {
|
|
37
|
+
const dir = jdkDir();
|
|
38
|
+
if (force && existsSync(dir))
|
|
39
|
+
rmSync(dir, { recursive: true, force: true });
|
|
40
|
+
if (!force && existsSync(dir)) {
|
|
41
|
+
const existing = findJavaHome(dir);
|
|
42
|
+
if (existing)
|
|
43
|
+
return existing;
|
|
44
|
+
}
|
|
45
|
+
mkdirSync(dir, { recursive: true });
|
|
46
|
+
const { osName, arch } = osArch();
|
|
47
|
+
const url = `https://api.adoptium.net/v3/binary/latest/21/ga/${osName}/${arch}/jdk/hotspot/normal/eclipse`;
|
|
48
|
+
const ext = osName === 'windows' ? 'zip' : 'tar.gz';
|
|
49
|
+
const archive = path.join(downloadCacheDir(), `temurin-21-${osName}-${arch}.${ext}`);
|
|
50
|
+
console.log(` • downloading Temurin JDK 21 (${osName}/${arch})…`);
|
|
51
|
+
await download(url, archive);
|
|
52
|
+
console.log(' • extracting JDK…');
|
|
53
|
+
await extract(archive, dir);
|
|
54
|
+
const javaHome = findJavaHome(dir);
|
|
55
|
+
if (!javaHome)
|
|
56
|
+
throw new Error('JDK extracted but no bin/java found under ' + dir);
|
|
57
|
+
return javaHome;
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ManagedManifest {
|
|
2
|
+
androidHome: string;
|
|
3
|
+
javaHome: string;
|
|
4
|
+
appiumBin?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function taqwrightHome(): string;
|
|
7
|
+
export declare const androidSdkDir: () => string;
|
|
8
|
+
export declare const jdkDir: () => string;
|
|
9
|
+
export declare const appiumDir: () => string;
|
|
10
|
+
export declare const appiumHomeDir: () => string;
|
|
11
|
+
export declare const downloadCacheDir: () => string;
|
|
12
|
+
export declare const manifestPath: () => string;
|
|
13
|
+
export declare function systemAndroidHome(): string | undefined;
|
|
14
|
+
export declare function readManifest(): ManagedManifest | undefined;
|
|
15
|
+
export declare function managedEnv(): NodeJS.ProcessEnv | undefined;
|
|
16
|
+
export declare function applyManagedEnv(): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
export function taqwrightHome() {
|
|
5
|
+
const override = process.env.TAQWRIGHT_HOME;
|
|
6
|
+
if (override && override.trim())
|
|
7
|
+
return path.resolve(override);
|
|
8
|
+
const home = os.homedir();
|
|
9
|
+
if (process.platform === 'darwin')
|
|
10
|
+
return path.join(home, 'Library', 'Caches', 'taqwright');
|
|
11
|
+
if (process.platform === 'win32') {
|
|
12
|
+
return path.join(process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local'), 'taqwright');
|
|
13
|
+
}
|
|
14
|
+
return path.join(process.env.XDG_CACHE_HOME || path.join(home, '.cache'), 'taqwright');
|
|
15
|
+
}
|
|
16
|
+
export const androidSdkDir = () => path.join(taqwrightHome(), 'android-sdk');
|
|
17
|
+
export const jdkDir = () => path.join(taqwrightHome(), 'jdk');
|
|
18
|
+
export const appiumDir = () => path.join(taqwrightHome(), 'appium');
|
|
19
|
+
export const appiumHomeDir = () => path.join(taqwrightHome(), 'appium-home');
|
|
20
|
+
export const downloadCacheDir = () => path.join(taqwrightHome(), 'downloads');
|
|
21
|
+
export const manifestPath = () => path.join(taqwrightHome(), 'manifest.json');
|
|
22
|
+
const exe = (name) => (process.platform === 'win32' ? `${name}.exe` : name);
|
|
23
|
+
export function systemAndroidHome() {
|
|
24
|
+
const captured = process.env.TAQWRIGHT_SYSTEM_ANDROID_HOME;
|
|
25
|
+
if (captured && captured.trim())
|
|
26
|
+
return captured;
|
|
27
|
+
if (!readManifest() && process.env.ANDROID_HOME?.trim())
|
|
28
|
+
return process.env.ANDROID_HOME;
|
|
29
|
+
const home = os.homedir();
|
|
30
|
+
const candidates = process.platform === 'darwin'
|
|
31
|
+
? [path.join(home, 'Library', 'Android', 'sdk')]
|
|
32
|
+
: process.platform === 'win32'
|
|
33
|
+
? [
|
|
34
|
+
path.join(process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local'), 'Android', 'Sdk'),
|
|
35
|
+
]
|
|
36
|
+
: [path.join(home, 'Android', 'Sdk')];
|
|
37
|
+
return candidates.find((c) => existsSync(c));
|
|
38
|
+
}
|
|
39
|
+
export function readManifest() {
|
|
40
|
+
try {
|
|
41
|
+
const f = manifestPath();
|
|
42
|
+
if (!existsSync(f))
|
|
43
|
+
return undefined;
|
|
44
|
+
const m = JSON.parse(readFileSync(f, 'utf8'));
|
|
45
|
+
if (!m || !m.androidHome || !m.javaHome)
|
|
46
|
+
return undefined;
|
|
47
|
+
return m;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function managedEnv() {
|
|
54
|
+
const m = readManifest();
|
|
55
|
+
if (!m)
|
|
56
|
+
return undefined;
|
|
57
|
+
const adb = path.join(m.androidHome, 'platform-tools', exe('adb'));
|
|
58
|
+
const java = path.join(m.javaHome, 'bin', exe('java'));
|
|
59
|
+
if (!existsSync(adb) || !existsSync(java))
|
|
60
|
+
return undefined;
|
|
61
|
+
const binDirs = [
|
|
62
|
+
path.join(m.javaHome, 'bin'),
|
|
63
|
+
path.join(m.androidHome, 'platform-tools'),
|
|
64
|
+
path.join(m.androidHome, 'cmdline-tools', 'latest', 'bin'),
|
|
65
|
+
path.join(m.androidHome, 'emulator'),
|
|
66
|
+
];
|
|
67
|
+
if (m.appiumBin)
|
|
68
|
+
binDirs.push(m.appiumBin);
|
|
69
|
+
return {
|
|
70
|
+
ANDROID_HOME: m.androidHome,
|
|
71
|
+
ANDROID_SDK_ROOT: m.androidHome,
|
|
72
|
+
JAVA_HOME: m.javaHome,
|
|
73
|
+
APPIUM_HOME: appiumHomeDir(),
|
|
74
|
+
PATH: binDirs.join(path.delimiter) + path.delimiter + (process.env.PATH ?? ''),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function applyManagedEnv() {
|
|
78
|
+
if (process.env.__TAQWRIGHT_MANAGED_APPLIED === '1')
|
|
79
|
+
return;
|
|
80
|
+
const m = managedEnv();
|
|
81
|
+
if (m) {
|
|
82
|
+
if (!process.env.TAQWRIGHT_SYSTEM_ANDROID_HOME && process.env.ANDROID_HOME?.trim()) {
|
|
83
|
+
process.env.TAQWRIGHT_SYSTEM_ANDROID_HOME = process.env.ANDROID_HOME;
|
|
84
|
+
}
|
|
85
|
+
Object.assign(process.env, m);
|
|
86
|
+
process.env.__TAQWRIGHT_MANAGED_APPLIED = '1';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export function quoteWin(tok) {
|
|
3
|
+
return /[\s&()[\]{}^=;!'+,`~]/.test(tok) ? `"${tok}"` : tok;
|
|
4
|
+
}
|
|
5
|
+
export function spawnTool(cmd, args, opts = {}) {
|
|
6
|
+
if (process.platform === 'win32') {
|
|
7
|
+
const line = [cmd, ...args].map(quoteWin).join(' ');
|
|
8
|
+
return spawn(line, { ...opts, shell: true });
|
|
9
|
+
}
|
|
10
|
+
return spawn(cmd, args, opts);
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Client as WebDriverClient } from 'webdriver';
|
|
2
|
+
import type { Platform } from '../types/index.js';
|
|
3
|
+
import type { HarLog } from '../network/har.js';
|
|
4
|
+
export interface TraceEntry {
|
|
5
|
+
action: string;
|
|
6
|
+
args: string;
|
|
7
|
+
startTs: number;
|
|
8
|
+
durationMs: number;
|
|
9
|
+
screenshot: string | null;
|
|
10
|
+
source: string | null;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface TraceTestInfo {
|
|
14
|
+
title: string;
|
|
15
|
+
status?: string;
|
|
16
|
+
duration?: number;
|
|
17
|
+
project?: {
|
|
18
|
+
name?: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface ToHtmlOptions {
|
|
22
|
+
har?: HarLog | null;
|
|
23
|
+
}
|
|
24
|
+
export declare class Tracer {
|
|
25
|
+
private readonly driver;
|
|
26
|
+
private readonly _platform;
|
|
27
|
+
private readonly entries;
|
|
28
|
+
private readonly startTs;
|
|
29
|
+
constructor(driver: WebDriverClient, _platform: Platform);
|
|
30
|
+
getStartTs(): number;
|
|
31
|
+
getEntries(): readonly TraceEntry[];
|
|
32
|
+
record<T>(action: string, args: unknown[], fn: () => Promise<T>): Promise<T>;
|
|
33
|
+
toHtml(info: TraceTestInfo, opts?: ToHtmlOptions): string;
|
|
34
|
+
}
|