@e2e-dev/testmu 0.0.2-nightly-20261021080401 → 0.0.2

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
@@ -2,10 +2,11 @@
2
2
 
3
3
  Run `@e2e-dev/mobile` tests on [TestMu AI](https://www.lambdatest.com) (formerly LambdaTest)
4
4
  Android emulators, iOS simulators, and real devices. Each worker slot leases one device,
5
- with your app installed, and releases it when the run ends.
5
+ with your app installed, and releases it when the run ends. `@e2e-dev/web` tests run on
6
+ its hosted Chrome and Edge; see [Browsers](#browsers).
6
7
 
7
8
  ```bash
8
- npm install --save-dev @e2e-dev/testmu
9
+ npm install --save-dev e2e @e2e-dev/mobile @e2e-dev/testmu
9
10
  ```
10
11
 
11
12
  ```ts title="e2e.config.ts"
@@ -36,6 +37,33 @@ Set `LT_USERNAME` and `LT_ACCESS_KEY` in the run environment, from
36
37
  See the [integration guide](https://e2e.tester.army/docs/integrations/testmu) for every
37
38
  option and the limits.
38
39
 
40
+ ## Browsers
41
+
42
+ `web({ browser: testmuBrowsers() })` runs a web target in TestMu AI's hosted Chrome or
43
+ Edge, one session per worker slot. It is exported from `@e2e-dev/testmu/web`, which needs
44
+ only `@e2e-dev/web`; the package root exports the device provider.
45
+
46
+ ```bash
47
+ npm install --save-dev e2e @e2e-dev/web @e2e-dev/testmu
48
+ ```
49
+
50
+ ```ts title="e2e.config.ts"
51
+ import type { E2EConfig } from 'e2e';
52
+ import { web } from '@e2e-dev/web';
53
+ import { testmuBrowsers } from '@e2e-dev/testmu/web';
54
+
55
+ export default {
56
+ targets: [{ engine: web({ browser: testmuBrowsers(), viewport: null }), app: { url: 'https://staging.example.com' } }],
57
+ workers: 4,
58
+ } satisfies E2EConfig;
59
+ ```
60
+
61
+ It reads the same `LT_USERNAME` and `LT_ACCESS_KEY`. `browserName` is `Chrome` (default)
62
+ or `MicrosoftEdge`, and `capabilities` takes `browserVersion` and `LT:Options` fields such
63
+ as `platform`, `geoLocation`, and `video`. See the
64
+ [integration guide](https://e2e.tester.army/docs/integrations/testmu) for the
65
+ defaults and the limits.
66
+
39
67
  ## License
40
68
 
41
69
  Apache-2.0
package/dist/.build.json CHANGED
@@ -1 +1 @@
1
- {"version":"0.0.2-nightly-20261021080401"}
1
+ {"version":"0.0.2"}
@@ -0,0 +1,26 @@
1
+ /** TestMu AI's hosted Chrome and Edge as a `BrowserProvider` for the web engine. */
2
+ import type { BrowserProvider } from '@e2e-dev/web';
3
+ /** The browsers the web engine can attach to over CDP: Chromium ones. */
4
+ export type TestmuBrowserName = 'Chrome' | 'MicrosoftEdge';
5
+ export interface TestmuBrowsersOptions {
6
+ /** `Chrome` when absent. */
7
+ readonly browserName?: TestmuBrowserName | undefined;
8
+ /**
9
+ * `browserVersion`, sent next to `browserName`, and `LT:Options` fields:
10
+ * `platform`, `geoLocation`, `timezone`, `video`, `tunnel`, and the rest
11
+ * TestMu AI takes. `platform` defaults to `Windows 11`, `build` to the run
12
+ * id, `project` to `e2e`, and `idleTimeout` to 600 seconds. `user`, `accessKey`, and `name` are not
13
+ * accepted: the provider sets them, from `LT_USERNAME`, `LT_ACCESS_KEY`,
14
+ * and the run.
15
+ */
16
+ readonly capabilities?: Readonly<Record<string, unknown>> | undefined;
17
+ }
18
+ /**
19
+ * TestMu AI browsers for `web({ browser: testmuBrowsers() })`: one session
20
+ * per worker slot. A TestMu AI session is its websocket: connecting to the
21
+ * CDP URL starts it and closing the connection ends it, so `acquire` only
22
+ * builds the URL and `release` has nothing to call. `LT_USERNAME` and
23
+ * `LT_ACCESS_KEY` come from the run's environment and never appear in a log
24
+ * line.
25
+ */
26
+ export declare function testmuBrowsers(options?: TestmuBrowsersOptions): BrowserProvider;
@@ -0,0 +1,101 @@
1
+ /** TestMu AI's hosted Chrome and Edge as a `BrowserProvider` for the web engine. */
2
+ import { ConfigurationError, obj, rejectUnknownKeys, validateJsonValue } from 'e2e/engine';
3
+ import { testmuCredentials } from './credentials.js';
4
+ import { DEFAULT_PROJECT, defaultSessionName } from './dashboard.js';
5
+ const OPTION_KEYS = Object.keys({
6
+ browserName: true,
7
+ capabilities: true,
8
+ });
9
+ const BROWSERS = ['Chrome', 'MicrosoftEdge'];
10
+ const RESERVED_CAPABILITIES = ['user', 'accessKey', 'name'];
11
+ const CDP_ENDPOINT = 'wss://cdp.lambdatest.com/puppeteer';
12
+ // The hub refuses a session without a platform.
13
+ const DEFAULT_PLATFORM = 'Windows 11';
14
+ // The hub's Edge CDP connect never completes without a user data directory.
15
+ const EDGE_USER_DATA_DIR = '--user-data-dir=remote-debug-profile-edge';
16
+ // The hub ends a CDP session after 300 s without client traffic, shorter than a slow test's gaps.
17
+ const DEFAULT_IDLE_TIMEOUT_SECONDS = 600;
18
+ /**
19
+ * TestMu AI browsers for `web({ browser: testmuBrowsers() })`: one session
20
+ * per worker slot. A TestMu AI session is its websocket: connecting to the
21
+ * CDP URL starts it and closing the connection ends it, so `acquire` only
22
+ * builds the URL and `release` has nothing to call. `LT_USERNAME` and
23
+ * `LT_ACCESS_KEY` come from the run's environment and never appear in a log
24
+ * line.
25
+ */
26
+ export function testmuBrowsers(options = {}) {
27
+ rejectUnknownKeys('testmuBrowsers()', options, OPTION_KEYS);
28
+ // Only an absent value takes the default: `null` from a JavaScript config is refused like any other.
29
+ const browserName = options.browserName === undefined ? 'Chrome' : options.browserName;
30
+ if (!BROWSERS.includes(browserName)) {
31
+ throw new ConfigurationError('INVALID_CONFIG', `testmuBrowsers: \`browserName\` must be one of ${BROWSERS.join(', ')}, got ${JSON.stringify(browserName)}`);
32
+ }
33
+ const capabilities = options.capabilities === undefined ? {} : options.capabilities;
34
+ if (!isPlainObject(capabilities)) {
35
+ throw new ConfigurationError('INVALID_CONFIG', 'testmuBrowsers: `capabilities` must be an object of `LT:Options` fields');
36
+ }
37
+ // An undefined value would replace a default and then vanish from the JSON.
38
+ const defined = obj(capabilities);
39
+ for (const [key, value] of Object.entries(defined)) {
40
+ try {
41
+ validateJsonValue(value, `testmuBrowsers: \`capabilities.${key}\``);
42
+ }
43
+ catch (error) {
44
+ // JSON.stringify turns a Map or a class instance into `{}`, a Date into a string, and NaN into null, so TestMu AI would get something else.
45
+ if (error instanceof ConfigurationError)
46
+ throw error;
47
+ throw new ConfigurationError('INVALID_CONFIG', error instanceof Error ? error.message : String(error));
48
+ }
49
+ }
50
+ if ('LT:Options' in capabilities) {
51
+ throw new ConfigurationError('INVALID_CONFIG', 'testmuBrowsers: pass `LT:Options` fields directly in `capabilities`, not nested under `LT:Options`');
52
+ }
53
+ if ('browserName' in capabilities) {
54
+ throw new ConfigurationError('INVALID_CONFIG', 'testmuBrowsers: set `browserName` as an option, not in `capabilities`');
55
+ }
56
+ const reserved = RESERVED_CAPABILITIES.filter((key) => key in capabilities);
57
+ if (reserved.length > 0) {
58
+ throw new ConfigurationError('INVALID_CONFIG', `testmuBrowsers: \`capabilities\` cannot set ${reserved.map((key) => `\`${key}\``).join(', ')}; the provider names each session, and reads LT_USERNAME and LT_ACCESS_KEY from the environment`);
59
+ }
60
+ const browserOptions = capabilities['browserOptions'];
61
+ if (browserOptions !== undefined && !(Array.isArray(browserOptions) && browserOptions.every((flag) => typeof flag === 'string'))) {
62
+ throw new ConfigurationError('INVALID_CONFIG', 'testmuBrowsers: `capabilities.browserOptions` must be an array of strings');
63
+ }
64
+ const { browserVersion, ...ltCapabilities } = defined;
65
+ const flags = browserOptions ?? [];
66
+ if (browserName === 'MicrosoftEdge' && !flags.some((flag) => flag.startsWith('--user-data-dir='))) {
67
+ ltCapabilities['browserOptions'] = [...flags, EDGE_USER_DATA_DIR];
68
+ }
69
+ return {
70
+ name: 'testmu-browsers',
71
+ async acquire(request) {
72
+ const { username, accessKey } = testmuCredentials(request.env);
73
+ const name = defaultSessionName(request);
74
+ const ltOptions = {
75
+ platform: DEFAULT_PLATFORM,
76
+ project: DEFAULT_PROJECT,
77
+ build: request.runId,
78
+ idleTimeout: DEFAULT_IDLE_TIMEOUT_SECONDS,
79
+ ...ltCapabilities,
80
+ name,
81
+ user: username,
82
+ accessKey,
83
+ };
84
+ request.log(`TestMu AI session "${name}" in build "${String(ltOptions['build'])}"`);
85
+ return {
86
+ id: `${request.targetName}:slot-${request.slot + 1}`,
87
+ cdpEndpoint: `${CDP_ENDPOINT}?capabilities=${encodeURIComponent(JSON.stringify({ browserName, ...(browserVersion === undefined ? {} : { browserVersion }), 'LT:Options': ltOptions }))}`,
88
+ };
89
+ },
90
+ async release() {
91
+ // Closing the CDP connection, which the engine does, ends the TestMu AI session.
92
+ },
93
+ };
94
+ }
95
+ /** A plain object: not null, an array, a Map, a Date, or another class instance. */
96
+ function isPlainObject(value) {
97
+ if (typeof value !== 'object' || value === null)
98
+ return false;
99
+ const prototype = Object.getPrototypeOf(value);
100
+ return prototype === Object.prototype || prototype === null;
101
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * How `testmu()` and `testmuBrowsers()` group and name their sessions on the
3
+ * TestMu AI dashboard, so a run's device and browser sessions read alike.
4
+ */
5
+ /** The dashboard project sessions are grouped under when none is set. */
6
+ export declare const DEFAULT_PROJECT = "e2e";
7
+ /** A worker slot's session name when none is set: `e2e-<run id>-<target>-<slot>`, slots counting from 1. */
8
+ export declare function defaultSessionName({ runId, targetName, slot }: {
9
+ readonly runId: string;
10
+ readonly targetName: string;
11
+ readonly slot: number;
12
+ }): string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * How `testmu()` and `testmuBrowsers()` group and name their sessions on the
3
+ * TestMu AI dashboard, so a run's device and browser sessions read alike.
4
+ */
5
+ /** The dashboard project sessions are grouped under when none is set. */
6
+ export const DEFAULT_PROJECT = 'e2e';
7
+ /** A worker slot's session name when none is set: `e2e-<run id>-<target>-<slot>`, slots counting from 1. */
8
+ export function defaultSessionName({ runId, targetName, slot }) {
9
+ return `e2e-${runId}-${targetName}-${slot + 1}`;
10
+ }
package/dist/index.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * `@e2e-dev/testmu` public surface: `testmu()`, a device provider that leases
3
3
  * TestMu AI (formerly LambdaTest) Android emulators, iOS simulators, and real
4
4
  * devices for `@e2e-dev/mobile` through agent-device's `@agent-device/testmu`
5
- * plugin.
5
+ * plugin. `testmuBrowsers()`, for TestMu AI's hosted Chrome and Edge on
6
+ * `@e2e-dev/web`, is exported from `@e2e-dev/testmu/web`.
6
7
  */
7
8
  export { testmu } from './provider.ts';
8
9
  export type { TestmuOptions } from './provider.ts';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * `@e2e-dev/testmu` public surface: `testmu()`, a device provider that leases
3
3
  * TestMu AI (formerly LambdaTest) Android emulators, iOS simulators, and real
4
4
  * devices for `@e2e-dev/mobile` through agent-device's `@agent-device/testmu`
5
- * plugin.
5
+ * plugin. `testmuBrowsers()`, for TestMu AI's hosted Chrome and Edge on
6
+ * `@e2e-dev/web`, is exported from `@e2e-dev/testmu/web`.
6
7
  */
7
8
  export { testmu } from './provider.js';
package/dist/provider.js CHANGED
@@ -10,12 +10,11 @@ import { isAbsolute, join, resolve } from 'node:path';
10
10
  import { ConfigurationError, rejectUnknownKeys } from 'e2e/engine';
11
11
  import { testmuCredentials } from './credentials.js';
12
12
  import { assertDriverVersion, installPlugin, startDriver, stopDriver } from './daemon.js';
13
+ import { DEFAULT_PROJECT, defaultSessionName } from './dashboard.js';
13
14
  import { LEASE_TTL_MS, startHeartbeat } from './heartbeat.js';
14
15
  import { findSession, sessionVideoUrl, testmuApiEndpoint } from './sessions.js';
15
16
  /** agent-device's name for TestMu AI, as the lease provider and the tenant. */
16
17
  const PROVIDER = 'testmu';
17
- /** The dashboard project sessions are grouped under when `project` is absent. */
18
- const DEFAULT_PROJECT = 'e2e';
19
18
  const DEVICE_TYPES = new Set(['virtual', 'real']);
20
19
  const ORIENTATIONS = new Set(['portrait', 'landscape']);
21
20
  /** Each device-feature option and the agent-device lease key it is allocated under. */
@@ -198,10 +197,10 @@ export function testmu(options) {
198
197
  * The dashboard name of a slot's session, unique among the run's slots of the
199
198
  * target so `record` can find the session by it within its build.
200
199
  */
201
- function slotSessionName(sessionName, { runId, targetName, slot, slots }) {
200
+ function slotSessionName(sessionName, request) {
202
201
  if (sessionName === undefined)
203
- return `e2e-${runId}-${targetName}-${slot + 1}`;
204
- return slots > 1 ? `${sessionName}-${slot + 1}` : sessionName;
202
+ return defaultSessionName(request);
203
+ return request.slots > 1 ? `${sessionName}-${request.slot + 1}` : sessionName;
205
204
  }
206
205
  /** `app` as the daemon reads it: an `lt://` id or URL as written, a local path resolved against the project root, never the daemon's working directory. */
207
206
  function appSource(app, projectRoot) {
package/dist/web.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * `@e2e-dev/testmu/web` public surface: `testmuBrowsers()`, a browser provider
3
+ * for TestMu AI's hosted Chrome and Edge on `@e2e-dev/web`. Its types never
4
+ * reference `@e2e-dev/mobile`, and the package root's never reference
5
+ * `@e2e-dev/web`, so a project installs only the engine it uses.
6
+ */
7
+ export { testmuBrowsers } from './browsers.ts';
8
+ export type { TestmuBrowserName, TestmuBrowsersOptions } from './browsers.ts';
package/dist/web.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * `@e2e-dev/testmu/web` public surface: `testmuBrowsers()`, a browser provider
3
+ * for TestMu AI's hosted Chrome and Edge on `@e2e-dev/web`. Its types never
4
+ * reference `@e2e-dev/mobile`, and the package root's never reference
5
+ * `@e2e-dev/web`, so a project installs only the engine it uses.
6
+ */
7
+ export { testmuBrowsers } from './browsers.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@e2e-dev/testmu",
3
- "version": "0.0.2-nightly-20261021080401",
4
- "description": "TestMu AI (formerly LambdaTest) hosted Android emulators, iOS simulators, and real devices for e2e mobile tests",
3
+ "version": "0.0.2",
4
+ "description": "TestMu AI (formerly LambdaTest) for e2e: hosted Android emulators, iOS simulators, and real devices for mobile tests, and hosted Chrome and Edge for web tests",
5
5
  "keywords": [
6
6
  "e2e",
7
7
  "end-to-end",
@@ -14,11 +14,16 @@
14
14
  "ios-simulator",
15
15
  "android-emulator",
16
16
  "agent-device",
17
+ "cloud-browsers",
18
+ "hosted-browsers",
19
+ "chrome",
20
+ "cdp",
17
21
  "ci"
18
22
  ],
19
23
  "license": "Apache-2.0",
20
24
  "contributors": [
21
- "Aman Kansal (https://github.com/amankansal-lt)"
25
+ "Aman Kansal (https://github.com/amankansal-lt)",
26
+ "Sahil Saw (https://github.com/SahilSawLT)"
22
27
  ],
23
28
  "repository": {
24
29
  "type": "git",
@@ -39,6 +44,10 @@
39
44
  ".": {
40
45
  "types": "./dist/index.d.ts",
41
46
  "default": "./dist/index.js"
47
+ },
48
+ "./web": {
49
+ "types": "./dist/web.d.ts",
50
+ "default": "./dist/web.js"
42
51
  }
43
52
  },
44
53
  "files": [
@@ -46,13 +55,23 @@
46
55
  "NOTICE"
47
56
  ],
48
57
  "peerDependencies": {
49
- "@e2e-dev/mobile": "0.12.4-nightly-20261021080401",
50
- "e2e": "0.21.3-nightly-20261021080401"
58
+ "@e2e-dev/mobile": ">=0.11.1 <1",
59
+ "@e2e-dev/web": ">=0.11.0 <1",
60
+ "e2e": ">=0.15.0 <1"
61
+ },
62
+ "peerDependenciesMeta": {
63
+ "@e2e-dev/mobile": {
64
+ "optional": true
65
+ },
66
+ "@e2e-dev/web": {
67
+ "optional": true
68
+ }
51
69
  },
52
70
  "devDependencies": {
53
- "@e2e-dev/mobile": "0.12.4-nightly-20261021080401",
71
+ "@e2e-dev/mobile": "0.12.4",
72
+ "@e2e-dev/web": "0.15.3",
54
73
  "@types/node": "26.6.2",
55
- "e2e": "0.21.3-nightly-20261021080401",
74
+ "e2e": "0.21.3",
56
75
  "typescript": "7.0.2",
57
76
  "vitest": "5.0.1"
58
77
  },
@@ -60,8 +79,8 @@
60
79
  "node": "^22.22.3 || >=24.8.0"
61
80
  },
62
81
  "dependencies": {
63
- "@agent-device/testmu": "0.21.28",
64
- "agent-device": "0.21.28"
82
+ "@agent-device/testmu": "0.21.29",
83
+ "agent-device": "0.21.29"
65
84
  },
66
85
  "scripts": {
67
86
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc --project tsconfig.build.json && node ../../scripts/stamp-dist.ts",