UNPKG

2.58 kBTypeScriptView Raw
1/// <reference types="node" resolution-mode="require"/>
2/// <reference types="node" resolution-mode="require"/>
3import child from 'node:child_process';
4import { EventEmitter } from 'node:events';
5import type { ChildProcess } from 'node:child_process';
6import type { WritableStreamBuffer } from 'stream-buffers';
7import type { Capabilities, Options, Workers } from '@wdio/types';
8/**
9 * WorkerInstance
10 * responsible for spawning a sub process to run the framework in and handle its
11 * session lifetime.
12 */
13export default class WorkerInstance extends EventEmitter implements Workers.Worker {
14 cid: string;
15 config: Options.Testrunner;
16 configFile: string;
17 caps: Capabilities.RemoteCapability;
18 capabilities: Capabilities.RemoteCapability;
19 specs: string[];
20 execArgv: string[];
21 retries: number;
22 stdout: WritableStreamBuffer;
23 stderr: WritableStreamBuffer;
24 childProcess?: ChildProcess;
25 sessionId?: string;
26 server?: Record<string, any>;
27 instances?: Record<string, {
28 sessionId: string;
29 }>;
30 isMultiremote?: boolean;
31 isBusy: boolean;
32 isKilled: boolean;
33 isReady: Promise<boolean>;
34 isSetup: Promise<boolean>;
35 isReadyResolver: (value: boolean | PromiseLike<boolean>) => void;
36 isSetupResolver: (value: boolean | PromiseLike<boolean>) => void;
37 /**
38 * assigns paramters to scope of instance
39 * @param {object} config parsed configuration object
40 * @param {string} cid capability id (e.g. 0-1)
41 * @param {string} configFile path to config file (for sub process to parse)
42 * @param {object} caps capability object
43 * @param {string[]} specs list of paths to test files to run in this worker
44 * @param {number} retries number of retries remaining
45 * @param {object} execArgv execution arguments for the test run
46 */
47 constructor(config: Options.Testrunner, { cid, configFile, caps, specs, execArgv, retries }: Workers.WorkerRunPayload, stdout: WritableStreamBuffer, stderr: WritableStreamBuffer);
48 /**
49 * spawns process to kick of wdio-runner
50 */
51 startProcess(): child.ChildProcess;
52 private _handleMessage;
53 private _handleError;
54 private _handleExit;
55 /**
56 * sends message to sub process to execute functions in wdio-runner
57 * @param command method to run in wdio-runner
58 * @param args arguments for functions to call
59 */
60 postMessage(command: string, args: Workers.WorkerMessageArgs, requiresSetup?: boolean): void;
61}
62//# sourceMappingURL=worker.d.ts.map
\No newline at end of file