UNPKG

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