@wdio/cli 7.20.9 → 8.0.0-alpha.213
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/bin/wdio.js +7 -1
- package/build/commands/config.d.ts +3 -3
- package/build/commands/config.d.ts.map +1 -1
- package/build/commands/config.js +56 -61
- package/build/commands/index.d.ts +2 -0
- package/build/commands/index.d.ts.map +1 -0
- package/build/commands/index.js +5 -0
- package/build/commands/install.d.ts +3 -3
- package/build/commands/install.d.ts.map +1 -1
- package/build/commands/install.js +27 -35
- package/build/commands/repl.d.ts +5 -5
- package/build/commands/repl.d.ts.map +1 -1
- package/build/commands/repl.js +15 -29
- package/build/commands/run.d.ts +3 -3
- package/build/commands/run.d.ts.map +1 -1
- package/build/commands/run.js +24 -33
- package/build/constants.d.ts +2 -1
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +45 -46
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +24 -41
- package/build/interface.d.ts +2 -2
- package/build/interface.d.ts.map +1 -1
- package/build/interface.js +27 -34
- package/build/launcher.d.ts +4 -4
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +59 -52
- package/build/types.d.ts +2 -2
- package/build/types.d.ts.map +1 -1
- package/build/types.js +1 -2
- package/build/utils.d.ts +1 -1
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +71 -92
- package/build/watcher.d.ts +1 -1
- package/build/watcher.d.ts.map +1 -1
- package/build/watcher.js +21 -24
- package/package.json +32 -26
package/build/commands/run.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const launcher_1 = __importDefault(require("../launcher"));
|
|
11
|
-
const watcher_1 = __importDefault(require("../watcher"));
|
|
12
|
-
const constants_1 = require("../constants");
|
|
13
|
-
exports.command = 'run <configPath>';
|
|
14
|
-
exports.desc = 'Run your WDIO configuration file to initialize your tests. (default)';
|
|
15
|
-
exports.cmdArgs = {
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import Launcher from '../launcher.js';
|
|
4
|
+
import Watcher from '../watcher.js';
|
|
5
|
+
import { missingConfigurationPrompt } from './config.js';
|
|
6
|
+
import { CLI_EPILOGUE } from '../constants.js';
|
|
7
|
+
export const command = 'run <configPath>';
|
|
8
|
+
export const desc = 'Run your WDIO configuration file to initialize your tests. (default)';
|
|
9
|
+
export const cmdArgs = {
|
|
16
10
|
watch: {
|
|
17
11
|
desc: 'Run WebdriverIO in watch mode',
|
|
18
12
|
type: 'boolean',
|
|
@@ -94,19 +88,18 @@ exports.cmdArgs = {
|
|
|
94
88
|
desc: 'Auto compilation options'
|
|
95
89
|
}
|
|
96
90
|
};
|
|
97
|
-
const builder = (yargs) => {
|
|
91
|
+
export const builder = (yargs) => {
|
|
98
92
|
return yargs
|
|
99
|
-
.options(
|
|
93
|
+
.options(cmdArgs)
|
|
100
94
|
.example('$0 run wdio.conf.js --suite foobar', 'Run suite on testsuite "foobar"')
|
|
101
95
|
.example('$0 run wdio.conf.js --spec ./tests/e2e/a.js --spec ./tests/e2e/b.js', 'Run suite on specific specs')
|
|
102
96
|
.example('$0 run wdio.conf.js --mochaOpts.timeout 60000', 'Run suite with custom Mocha timeout')
|
|
103
97
|
.example('$0 run wdio.conf.js --autoCompileOpts.autoCompile=false', 'Disable auto-loading of ts-node or @babel/register')
|
|
104
98
|
.example('$0 run wdio.conf.js --autoCompileOpts.tsNodeOpts.project=configs/bdd-tsconfig.json', 'Run suite with ts-node using custom tsconfig.json')
|
|
105
|
-
.epilogue(
|
|
99
|
+
.epilogue(CLI_EPILOGUE)
|
|
106
100
|
.help();
|
|
107
101
|
};
|
|
108
|
-
|
|
109
|
-
function launchWithStdin(wdioConfPath, params) {
|
|
102
|
+
export function launchWithStdin(wdioConfPath, params) {
|
|
110
103
|
let stdinData = '';
|
|
111
104
|
const stdin = process.openStdin();
|
|
112
105
|
stdin.setEncoding('utf8');
|
|
@@ -120,37 +113,36 @@ function launchWithStdin(wdioConfPath, params) {
|
|
|
120
113
|
launch(wdioConfPath, params);
|
|
121
114
|
});
|
|
122
115
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const launcher = new launcher_1.default(wdioConfPath, params);
|
|
116
|
+
export function launch(wdioConfPath, params) {
|
|
117
|
+
const launcher = new Launcher(wdioConfPath, params);
|
|
126
118
|
return launcher.run()
|
|
127
119
|
.then((...args) => {
|
|
128
120
|
/* istanbul ignore if */
|
|
129
|
-
if (!process.env.
|
|
121
|
+
if (!process.env.VITEST_WORKER_ID) {
|
|
130
122
|
process.exit(...args);
|
|
131
123
|
}
|
|
132
124
|
})
|
|
133
125
|
.catch(err => {
|
|
134
126
|
console.error(err);
|
|
135
127
|
/* istanbul ignore if */
|
|
136
|
-
if (!process.env.
|
|
128
|
+
if (!process.env.VITEST_WORKER_ID) {
|
|
137
129
|
process.exit(1);
|
|
138
130
|
}
|
|
139
131
|
});
|
|
140
132
|
}
|
|
141
|
-
|
|
142
|
-
async function handler(argv) {
|
|
133
|
+
export async function handler(argv) {
|
|
143
134
|
const { configPath, ...params } = argv;
|
|
144
|
-
if (!
|
|
145
|
-
|
|
135
|
+
if (!fs.existsSync(configPath)) {
|
|
136
|
+
const configFullPath = path.join(process.cwd(), configPath);
|
|
137
|
+
await missingConfigurationPrompt('run', configFullPath);
|
|
146
138
|
}
|
|
147
|
-
const localConf =
|
|
148
|
-
const wdioConf = configPath || (
|
|
139
|
+
const localConf = path.join(process.cwd(), 'wdio.conf.js');
|
|
140
|
+
const wdioConf = configPath || (fs.existsSync(localConf) ? localConf : undefined);
|
|
149
141
|
/**
|
|
150
142
|
* if `--watch` param is set, run launcher in watch mode
|
|
151
143
|
*/
|
|
152
144
|
if (params.watch) {
|
|
153
|
-
const watcher = new
|
|
145
|
+
const watcher = new Watcher(wdioConf, params);
|
|
154
146
|
return watcher.watch();
|
|
155
147
|
}
|
|
156
148
|
/**
|
|
@@ -169,4 +161,3 @@ async function handler(argv) {
|
|
|
169
161
|
*/
|
|
170
162
|
launchWithStdin(wdioConf, params);
|
|
171
163
|
}
|
|
172
|
-
exports.handler = handler;
|
package/build/constants.d.ts
CHANGED
package/build/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C,eAAO,MAAM,GAAG,KAA6B,CAAA;AAE7C,eAAO,MAAM,YAAY,QAAqE,CAAA;AAE9F,eAAO,MAAM,kBAAkB;;;;;CAK9B,CAAA;AAED,eAAO,MAAM,mBAAmB,wFAI/B,CAAA;AAED,eAAO,MAAM,6BAA6B,iHAIzC,CAAA;AAED,eAAO,MAAM,iCAAiC,8CAG7C,CAAA;AAED,eAAO,MAAM,WAAW,KAAK,CAAA;AAE7B,eAAO,MAAM,cAAc;;;;CAI1B,CAAA;AAED,eAAO,MAAM,UAAU;;;;CAItB,CAAA;AAED,eAAO,MAAM,uBAAuB,iGAI1B,CAAA;AAEV,eAAO,MAAM,gBAAgB;;;;CAInB,CAAA;AAEV,eAAO,MAAM,wBAAwB,gQAQpC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4ErB,CAAA;AAEV,eAAO,MAAM,eAAe,0NAMlB,CAAA;AAEV,eAAO,MAAM,gBAAgB,4BAGnB,CAAA;AAEV,eAAO,MAAM,aAAa,+BAIhB,CAAA;AAEV,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;oBAgBqB,YAAY;;;;;;;;;oBAMZ,YAAY;;;;;;;;;oBAyBZ,YAAY;;;;;;;oBAkDZ,YAAY;;;;;;;;oBAMZ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAsCpC,YAAY;oBACY,YAAY;;;;;;;uBAWpC,YAAY;oBACY,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgDR,MAAM,EAAE;;;;;;;;;;IA6BzD,CAAA"}
|
package/build/constants.js
CHANGED
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
exports.EXCLUSIVE_SERVICES = {
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { validateServiceAnswers, hasFile, getDefaultFiles } from './utils.js';
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
export const pkg = require('../package.json');
|
|
5
|
+
export const CLI_EPILOGUE = `Documentation: https://webdriver.io\n@wdio/cli (v${pkg.version})`;
|
|
6
|
+
export const EXCLUSIVE_SERVICES = {
|
|
8
7
|
'wdio-chromedriver-service': {
|
|
9
8
|
services: ['@wdio/selenium-standalone-service'],
|
|
10
9
|
message: '@wdio/selenium-standalone-service already includes chromedriver'
|
|
11
10
|
}
|
|
12
11
|
};
|
|
13
|
-
|
|
12
|
+
export const CONFIG_HELPER_INTRO = `
|
|
14
13
|
=========================
|
|
15
14
|
WDIO Configuration Helper
|
|
16
15
|
=========================
|
|
17
16
|
`;
|
|
18
|
-
|
|
17
|
+
export const CONFIG_HELPER_SUCCESS_MESSAGE = `
|
|
19
18
|
Configuration file was created successfully!
|
|
20
19
|
To run your tests, execute:
|
|
21
20
|
$ npx wdio run %swdio.conf.%s
|
|
22
21
|
`;
|
|
23
|
-
|
|
22
|
+
export const DEPENDENCIES_INSTALLATION_MESSAGE = `
|
|
24
23
|
To install dependencies, execute:
|
|
25
24
|
%s
|
|
26
25
|
`;
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export const NPM_INSTALL = '';
|
|
27
|
+
export const ANDROID_CONFIG = {
|
|
29
28
|
platformName: 'Android',
|
|
30
29
|
automationName: 'UiAutomator2',
|
|
31
30
|
deviceName: 'Test'
|
|
32
31
|
};
|
|
33
|
-
|
|
32
|
+
export const IOS_CONFIG = {
|
|
34
33
|
platformName: 'iOS',
|
|
35
34
|
automationName: 'XCUITest',
|
|
36
35
|
deviceName: 'iPhone Simulator'
|
|
37
36
|
};
|
|
38
|
-
|
|
37
|
+
export const COMPILER_OPTION_ANSWERS = [
|
|
39
38
|
'Babel (https://babeljs.io/)',
|
|
40
39
|
'TypeScript (https://www.typescriptlang.org/)',
|
|
41
40
|
'No!'
|
|
42
41
|
];
|
|
43
|
-
|
|
44
|
-
babel:
|
|
45
|
-
ts:
|
|
46
|
-
nil:
|
|
42
|
+
export const COMPILER_OPTIONS = {
|
|
43
|
+
babel: COMPILER_OPTION_ANSWERS[0],
|
|
44
|
+
ts: COMPILER_OPTION_ANSWERS[1],
|
|
45
|
+
nil: COMPILER_OPTION_ANSWERS[2]
|
|
47
46
|
};
|
|
48
|
-
|
|
47
|
+
export const TS_COMPILER_INSTRUCTIONS = `To have TypeScript support please add the following packages to your "types" list:
|
|
49
48
|
{
|
|
50
49
|
"compilerOptions": {
|
|
51
50
|
"types": ["node", %s]
|
|
@@ -58,7 +57,7 @@ For for information on TypeScript integration check out: https://webdriver.io/do
|
|
|
58
57
|
* We have to use a string hash for value because InquirerJS default values do not work if we have
|
|
59
58
|
* objects as a `value` to be stored from the user's answers.
|
|
60
59
|
*/
|
|
61
|
-
|
|
60
|
+
export const SUPPORTED_PACKAGES = {
|
|
62
61
|
runner: [
|
|
63
62
|
{ name: 'local', value: '@wdio/local-runner$--$local' }
|
|
64
63
|
],
|
|
@@ -135,34 +134,34 @@ exports.SUPPORTED_PACKAGES = {
|
|
|
135
134
|
{ name: 'azure-devops', value: '@gmangiapelo/wdio-azure-devops-service$--$azure-devops' }
|
|
136
135
|
]
|
|
137
136
|
};
|
|
138
|
-
|
|
137
|
+
export const BACKEND_CHOICES = [
|
|
139
138
|
'On my local machine',
|
|
140
139
|
'In the cloud using Experitest',
|
|
141
140
|
'In the cloud using Sauce Labs',
|
|
142
141
|
'In the cloud using Browserstack or Testingbot or LambdaTest or a different service',
|
|
143
142
|
'I have my own Selenium cloud'
|
|
144
143
|
];
|
|
145
|
-
|
|
144
|
+
export const PROTOCOL_OPTIONS = [
|
|
146
145
|
'https',
|
|
147
146
|
'http'
|
|
148
147
|
];
|
|
149
|
-
|
|
148
|
+
export const REGION_OPTION = [
|
|
150
149
|
'us',
|
|
151
150
|
'eu',
|
|
152
151
|
'apac'
|
|
153
152
|
];
|
|
154
|
-
|
|
153
|
+
export const QUESTIONNAIRE = [{
|
|
155
154
|
type: 'list',
|
|
156
155
|
name: 'runner',
|
|
157
156
|
message: 'Where should your tests be launched?',
|
|
158
|
-
choices:
|
|
157
|
+
choices: SUPPORTED_PACKAGES.runner,
|
|
159
158
|
// only ask if there are more than 1 runner to pick from
|
|
160
|
-
when: /* istanbul ignore next */ () =>
|
|
159
|
+
when: /* istanbul ignore next */ () => SUPPORTED_PACKAGES.runner.length > 1
|
|
161
160
|
}, {
|
|
162
161
|
type: 'list',
|
|
163
162
|
name: 'backend',
|
|
164
163
|
message: 'Where is your automation backend located?',
|
|
165
|
-
choices:
|
|
164
|
+
choices: BACKEND_CHOICES
|
|
166
165
|
}, {
|
|
167
166
|
type: 'input',
|
|
168
167
|
name: 'hostname',
|
|
@@ -197,7 +196,7 @@ exports.QUESTIONNAIRE = [{
|
|
|
197
196
|
name: 'expEnvProtocol',
|
|
198
197
|
message: 'Choose a protocol for environment variable',
|
|
199
198
|
default: 'https',
|
|
200
|
-
choices:
|
|
199
|
+
choices: PROTOCOL_OPTIONS,
|
|
201
200
|
when: /* istanbul ignore next */ (answers) => {
|
|
202
201
|
return answers.backend === 'In the cloud using Experitest' && answers.expEnvPort !== '80' && answers.expEnvPort !== '443';
|
|
203
202
|
}
|
|
@@ -249,7 +248,7 @@ exports.QUESTIONNAIRE = [{
|
|
|
249
248
|
type: 'list',
|
|
250
249
|
name: 'region',
|
|
251
250
|
message: 'In which region do you want to run your Sauce Labs tests in?',
|
|
252
|
-
choices:
|
|
251
|
+
choices: REGION_OPTION,
|
|
253
252
|
when: /* istanbul ignore next */ (answers) => !answers.headless && answers.backend === 'In the cloud using Sauce Labs'
|
|
254
253
|
}, {
|
|
255
254
|
type: 'input',
|
|
@@ -273,22 +272,22 @@ exports.QUESTIONNAIRE = [{
|
|
|
273
272
|
type: 'list',
|
|
274
273
|
name: 'framework',
|
|
275
274
|
message: 'Which framework do you want to use?',
|
|
276
|
-
choices:
|
|
275
|
+
choices: SUPPORTED_PACKAGES.framework,
|
|
277
276
|
}, {
|
|
278
277
|
type: 'list',
|
|
279
278
|
name: 'isUsingCompiler',
|
|
280
279
|
message: 'Do you want to use a compiler?',
|
|
281
|
-
choices:
|
|
282
|
-
default: /* istanbul ignore next */ () =>
|
|
283
|
-
?
|
|
284
|
-
:
|
|
285
|
-
?
|
|
286
|
-
:
|
|
280
|
+
choices: COMPILER_OPTION_ANSWERS,
|
|
281
|
+
default: /* istanbul ignore next */ () => hasFile('babel.config.js')
|
|
282
|
+
? COMPILER_OPTIONS.babel // default to Babel
|
|
283
|
+
: hasFile('tsconfig.json')
|
|
284
|
+
? COMPILER_OPTIONS.ts // default to TypeScript
|
|
285
|
+
: COMPILER_OPTIONS.nil // default to no compiler
|
|
287
286
|
}, {
|
|
288
287
|
type: 'input',
|
|
289
288
|
name: 'specs',
|
|
290
289
|
message: 'Where are your test specs located?',
|
|
291
|
-
default: (answers) =>
|
|
290
|
+
default: (answers) => getDefaultFiles(answers, './test/specs/**/*'),
|
|
292
291
|
when: /* istanbul ignore next */ (answers) => answers.framework.match(/(mocha|jasmine)/)
|
|
293
292
|
}, {
|
|
294
293
|
type: 'input',
|
|
@@ -300,7 +299,7 @@ exports.QUESTIONNAIRE = [{
|
|
|
300
299
|
type: 'input',
|
|
301
300
|
name: 'stepDefinitions',
|
|
302
301
|
message: 'Where are your step definitions located?',
|
|
303
|
-
default: (answers) =>
|
|
302
|
+
default: (answers) => getDefaultFiles(answers, './features/step-definitions/steps'),
|
|
304
303
|
when: /* istanbul ignore next */ (answers) => answers.framework.includes('cucumber')
|
|
305
304
|
}, {
|
|
306
305
|
type: 'confirm',
|
|
@@ -318,16 +317,16 @@ exports.QUESTIONNAIRE = [{
|
|
|
318
317
|
name: 'pages',
|
|
319
318
|
message: 'Where are your page objects located?',
|
|
320
319
|
default: /* istanbul ignore next */ (answers) => (answers.framework.match(/(mocha|jasmine)/)
|
|
321
|
-
?
|
|
322
|
-
:
|
|
320
|
+
? getDefaultFiles(answers, './test/pageobjects/**/*')
|
|
321
|
+
: getDefaultFiles(answers, './features/pageobjects/**/*')),
|
|
323
322
|
when: /* istanbul ignore next */ (answers) => answers.generateTestFiles && answers.usePageObjects
|
|
324
323
|
}, {
|
|
325
324
|
type: 'checkbox',
|
|
326
325
|
name: 'reporters',
|
|
327
326
|
message: 'Which reporter do you want to use?',
|
|
328
|
-
choices:
|
|
327
|
+
choices: SUPPORTED_PACKAGES.reporter,
|
|
329
328
|
// @ts-ignore
|
|
330
|
-
default: [
|
|
329
|
+
default: [SUPPORTED_PACKAGES.reporter.find(
|
|
331
330
|
/* istanbul ignore next */
|
|
332
331
|
({ name }) => name === 'spec').value
|
|
333
332
|
]
|
|
@@ -335,19 +334,19 @@ exports.QUESTIONNAIRE = [{
|
|
|
335
334
|
type: 'checkbox',
|
|
336
335
|
name: 'plugins',
|
|
337
336
|
message: 'Do you want to add a plugin to your test setup?',
|
|
338
|
-
choices:
|
|
337
|
+
choices: SUPPORTED_PACKAGES.plugin,
|
|
339
338
|
default: []
|
|
340
339
|
}, {
|
|
341
340
|
type: 'checkbox',
|
|
342
341
|
name: 'services',
|
|
343
342
|
message: 'Do you want to add a service to your test setup?',
|
|
344
|
-
choices:
|
|
343
|
+
choices: SUPPORTED_PACKAGES.service,
|
|
345
344
|
// @ts-ignore
|
|
346
|
-
default: [
|
|
345
|
+
default: [SUPPORTED_PACKAGES.service.find(
|
|
347
346
|
/* istanbul ignore next */
|
|
348
347
|
({ name }) => name === 'chromedriver').value
|
|
349
348
|
],
|
|
350
|
-
validate: /* istanbul ignore next */ (answers) =>
|
|
349
|
+
validate: /* istanbul ignore next */ (answers) => validateServiceAnswers(answers)
|
|
351
350
|
}, {
|
|
352
351
|
type: 'input',
|
|
353
352
|
name: 'outputDir',
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,QAAQ,MAAM,eAAe,CAAA;AAqBpC,eAAO,MAAM,GAAG,qBA0Df,CAAA;AAED,eAAe,QAAQ,CAAA;AACvB,cAAc,YAAY,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.run = void 0;
|
|
21
|
-
const fs_1 = __importDefault(require("fs"));
|
|
22
|
-
const path_1 = __importDefault(require("path"));
|
|
23
|
-
const yargs_1 = __importDefault(require("yargs/yargs"));
|
|
24
|
-
const helpers_1 = require("yargs/helpers");
|
|
25
|
-
const launcher_1 = __importDefault(require("./launcher"));
|
|
26
|
-
const run_1 = require("./commands/run");
|
|
27
|
-
const constants_1 = require("./constants");
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import url from 'node:url';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import yargs from 'yargs';
|
|
5
|
+
import { hideBin } from 'yargs/helpers';
|
|
6
|
+
import Launcher from './launcher.js';
|
|
7
|
+
import { commands } from './commands/index.js';
|
|
8
|
+
import { handler, cmdArgs } from './commands/run.js';
|
|
9
|
+
import { CLI_EPILOGUE } from './constants.js';
|
|
10
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
28
11
|
const DEFAULT_CONFIG_FILENAME = 'wdio.conf.js';
|
|
29
12
|
const DESCRIPTION = [
|
|
30
13
|
'The `wdio` command allows you run and manage your WebdriverIO test suite.',
|
|
@@ -37,9 +20,10 @@ const DESCRIPTION = [
|
|
|
37
20
|
'',
|
|
38
21
|
'For more information, visit: https://webdriver.io/docs/clioptions'
|
|
39
22
|
];
|
|
40
|
-
const run = async () => {
|
|
41
|
-
const
|
|
42
|
-
|
|
23
|
+
export const run = async () => {
|
|
24
|
+
const commandDir = path.join(__dirname, 'commands');
|
|
25
|
+
const argv = yargs(hideBin(process.argv))
|
|
26
|
+
.command(commands)
|
|
43
27
|
.example('wdio run wdio.conf.js --suite foobar', 'Run suite on testsuite "foobar"')
|
|
44
28
|
.example('wdio run wdio.conf.js --spec ./tests/e2e/a.js --spec ./tests/e2e/b.js', 'Run suite on specific specs')
|
|
45
29
|
.example('wdio run wdio.conf.js --spec ./tests/e2e/a.feature:5', 'Run scenario by line number')
|
|
@@ -48,14 +32,14 @@ const run = async () => {
|
|
|
48
32
|
.example('wdio install reporter spec', 'Install @wdio/spec-reporter')
|
|
49
33
|
.example('wdio repl chrome -u <SAUCE_USERNAME> -k <SAUCE_ACCESS_KEY>', 'Run repl in Sauce Labs cloud')
|
|
50
34
|
.updateStrings({ 'Commands:': `${DESCRIPTION.join('\n')}\n\nCommands:` })
|
|
51
|
-
.epilogue(
|
|
35
|
+
.epilogue(CLI_EPILOGUE);
|
|
52
36
|
/**
|
|
53
37
|
* parse CLI arguments according to what run expects, without this adding
|
|
54
38
|
* `--spec ./test.js` results in propagating the spec parameter as a
|
|
55
39
|
* string while in reality is should be parsed into a array of strings
|
|
56
40
|
*/
|
|
57
41
|
if (!process.argv.find((arg) => arg === '--help')) {
|
|
58
|
-
argv.options(
|
|
42
|
+
argv.options(cmdArgs);
|
|
59
43
|
}
|
|
60
44
|
/**
|
|
61
45
|
* The only way we reach this point is if the user runs the binary without a command (i.e. wdio wdio.conf.js)
|
|
@@ -66,24 +50,23 @@ const run = async () => {
|
|
|
66
50
|
* we don't have to check that again here.
|
|
67
51
|
*/
|
|
68
52
|
const params = await argv.parse();
|
|
69
|
-
const supportedCommands =
|
|
70
|
-
.readdirSync(
|
|
53
|
+
const supportedCommands = fs
|
|
54
|
+
.readdirSync(commandDir)
|
|
71
55
|
.map((file) => file.slice(0, -3));
|
|
72
56
|
if (params._ && !params._.find((param) => supportedCommands.includes(param))) {
|
|
73
57
|
const args = {
|
|
74
58
|
...params,
|
|
75
|
-
configPath:
|
|
59
|
+
configPath: path.resolve(process.cwd(), params._[0] && params._[0].toString() || DEFAULT_CONFIG_FILENAME)
|
|
76
60
|
};
|
|
77
|
-
return
|
|
78
|
-
const output = await new Promise((resolve) => ((
|
|
61
|
+
return handler(args).catch(async (err) => {
|
|
62
|
+
const output = await new Promise((resolve) => (yargs(hideBin(process.argv)).parse('--help', (err, argv, output) => resolve(output))));
|
|
79
63
|
console.error(`${output}\n\n${err.stack}`);
|
|
80
64
|
/* istanbul ignore if */
|
|
81
|
-
if (!process.env.
|
|
65
|
+
if (!process.env.VITEST_WORKER_ID) {
|
|
82
66
|
process.exit(1);
|
|
83
67
|
}
|
|
84
68
|
});
|
|
85
69
|
}
|
|
86
70
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
__exportStar(require("./types"), exports);
|
|
71
|
+
export default Launcher;
|
|
72
|
+
export * from './types.js';
|
package/build/interface.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
3
|
import type { Options, Workers } from '@wdio/types';
|
|
4
|
-
import { HookError } from './utils';
|
|
4
|
+
import { HookError } from './utils.js';
|
|
5
5
|
interface TestError {
|
|
6
6
|
type: string;
|
|
7
7
|
message: string;
|
package/build/interface.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,KAAK,EAAE,OAAO,EAAgB,OAAO,EAAE,MAAM,aAAa,CAAA;AAEjE,OAAO,EAAiB,SAAS,EAAE,MAAM,YAAY,CAAA;AAIrD,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,iBAAiB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,GAAG,CAAA;IACb,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,KAAK,CAAC,EAAE,SAAS,CAAA;CACpB;AAED,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,YAAY;IAyBjD,OAAO,CAAC,OAAO;IACR,cAAc,EAAE,MAAM;IAC7B,OAAO,CAAC,YAAY;IA1BjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM;;;;;MAKZ;IAED,OAAO,CAAC,KAAK,CAAsC;IACnD,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,qBAAqB,CAAQ;IAErC,OAAO,CAAC,aAAa,CAAI;IACzB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,SAAS,CAMZ;gBAGO,OAAO,EAAE,OAAO,CAAC,UAAU,EAC5B,cAAc,EAAE,MAAM,EACrB,YAAY,UAAQ;IAuBhC,KAAK;IAqBL,OAAO;IAWP,aAAa,CAAE,GAAG,EAAE,MAAM;IAI1B,WAAW,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,SAAI;IAKxD,UAAU,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,SAAI;IAIvD,aAAa,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,SAAI;IAI1D,UAAU,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG;IAI1C,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,SAAI,EAAE,OAAO,SAAK,EAAE,OAAO,GAAE,QAAmB;IAYrG,WAAW,CAAE,OAAO,EAAE,iBAAiB;IAUvC,YAAY,CAAE,KAAK,GAAE,MAAM,EAAO;IAOlC;;OAEG;IACH,MAAM,CAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,GAAG,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE;IASrE;;OAEG;IACH,QAAQ,CAAE,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IA2BrF;;OAEG;IACH,GAAG,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAMnB,YAAY,CAAE,KAAK,EAAE,SAAS;IAI9B;;OAEG;IACH,SAAS,CAAE,KAAK,EAAE,iBAAiB;IA8CnC,aAAa;IAgBb,cAAc;IAYd,YAAY;IAaZ,QAAQ;CAQX"}
|
package/build/interface.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const events_1 = require("events");
|
|
8
|
-
const logger_1 = __importDefault(require("@wdio/logger"));
|
|
9
|
-
const utils_1 = require("./utils");
|
|
10
|
-
const log = (0, logger_1.default)('@wdio/cli');
|
|
11
|
-
class WDIOCLInterface extends events_1.EventEmitter {
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import chalk, { supportsColor } from 'chalk';
|
|
3
|
+
import logger from '@wdio/logger';
|
|
4
|
+
import { getRunnerName } from './utils.js';
|
|
5
|
+
const log = logger('@wdio/cli');
|
|
6
|
+
export default class WDIOCLInterface extends EventEmitter {
|
|
12
7
|
constructor(_config, totalWorkerCnt, _isWatchMode = false) {
|
|
13
8
|
super();
|
|
14
9
|
this._config = _config;
|
|
@@ -33,7 +28,7 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
33
28
|
* `FORCE_COLOR=1` - forcibly enable colors
|
|
34
29
|
* `FORCE_COLOR=0` - forcibly disable colors
|
|
35
30
|
*/
|
|
36
|
-
this.hasAnsiSupport =
|
|
31
|
+
this.hasAnsiSupport = supportsColor && supportsColor.hasBasic;
|
|
37
32
|
this.totalWorkerCnt = totalWorkerCnt;
|
|
38
33
|
this._isWatchMode = _isWatchMode;
|
|
39
34
|
this._specFileRetries = _config.specFileRetries || 0;
|
|
@@ -62,27 +57,27 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
62
57
|
};
|
|
63
58
|
}
|
|
64
59
|
onStart() {
|
|
65
|
-
this.log(
|
|
60
|
+
this.log(chalk.bold(`\nExecution of ${chalk.blue(this.totalWorkerCnt)} workers started at`), this._start.toISOString());
|
|
66
61
|
if (this._inDebugMode) {
|
|
67
|
-
this.log(
|
|
62
|
+
this.log(chalk.bgYellow.black('DEBUG mode enabled!'));
|
|
68
63
|
}
|
|
69
64
|
if (this._isWatchMode) {
|
|
70
|
-
this.log(
|
|
65
|
+
this.log(chalk.bgYellow.black('WATCH mode enabled!'));
|
|
71
66
|
}
|
|
72
67
|
this.log('');
|
|
73
68
|
}
|
|
74
69
|
onSpecRunning(rid) {
|
|
75
|
-
this.onJobComplete(rid, this._jobs.get(rid), 0,
|
|
70
|
+
this.onJobComplete(rid, this._jobs.get(rid), 0, chalk.bold.cyan('RUNNING'));
|
|
76
71
|
}
|
|
77
72
|
onSpecRetry(rid, job, retries = 0) {
|
|
78
73
|
const delayMsg = this._specFileRetriesDelay > 0 ? ` after ${this._specFileRetriesDelay}s` : '';
|
|
79
|
-
this.onJobComplete(rid, job, retries,
|
|
74
|
+
this.onJobComplete(rid, job, retries, chalk.bold(chalk.yellow('RETRYING') + delayMsg));
|
|
80
75
|
}
|
|
81
76
|
onSpecPass(rid, job, retries = 0) {
|
|
82
|
-
this.onJobComplete(rid, job, retries,
|
|
77
|
+
this.onJobComplete(rid, job, retries, chalk.bold.green('PASSED'));
|
|
83
78
|
}
|
|
84
79
|
onSpecFailure(rid, job, retries = 0) {
|
|
85
|
-
this.onJobComplete(rid, job, retries,
|
|
80
|
+
this.onJobComplete(rid, job, retries, chalk.bold.red('FAILED'));
|
|
86
81
|
}
|
|
87
82
|
onSpecSkip(rid, job) {
|
|
88
83
|
this.onJobComplete(rid, job, 0, 'SKIPPED', log.info);
|
|
@@ -90,7 +85,7 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
90
85
|
onJobComplete(cid, job, retries = 0, message = '', _logger = this.log) {
|
|
91
86
|
const details = [`[${cid}]`, message];
|
|
92
87
|
if (job) {
|
|
93
|
-
details.push('in',
|
|
88
|
+
details.push('in', getRunnerName(job.caps), this.getFilenames(job.specs));
|
|
94
89
|
}
|
|
95
90
|
if (retries > 0) {
|
|
96
91
|
details.push(`(${retries} retries)`);
|
|
@@ -98,13 +93,12 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
98
93
|
return _logger(...details);
|
|
99
94
|
}
|
|
100
95
|
onTestError(payload) {
|
|
101
|
-
var _a, _b, _c;
|
|
102
96
|
const error = {
|
|
103
|
-
type:
|
|
104
|
-
message:
|
|
105
|
-
stack:
|
|
97
|
+
type: payload.error?.type || 'Error',
|
|
98
|
+
message: payload.error?.message || (typeof payload.error === 'string' ? payload.error : 'Unknown error.'),
|
|
99
|
+
stack: payload.error?.stack
|
|
106
100
|
};
|
|
107
|
-
return this.log(`[${payload.cid}]`, `${
|
|
101
|
+
return this.log(`[${payload.cid}]`, `${chalk.red(error.type)} in "${payload.fullTitle}"\n${chalk.red(error.stack || error.message)}`);
|
|
108
102
|
}
|
|
109
103
|
getFilenames(specs = []) {
|
|
110
104
|
if (specs.length > 0) {
|
|
@@ -161,7 +155,7 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
161
155
|
return args;
|
|
162
156
|
}
|
|
163
157
|
logHookError(error) {
|
|
164
|
-
return this.log(`${
|
|
158
|
+
return this.log(`${chalk.red(error.name)} in "${error.origin}"\n${chalk.red(error.stack || error.message)}`);
|
|
165
159
|
}
|
|
166
160
|
/**
|
|
167
161
|
* event handler that is triggered when runner sends up events
|
|
@@ -172,7 +166,7 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
172
166
|
return;
|
|
173
167
|
}
|
|
174
168
|
if (event.origin === 'debugger' && event.name === 'start') {
|
|
175
|
-
this.log(
|
|
169
|
+
this.log(chalk.yellow(event.params.introMessage));
|
|
176
170
|
this._inDebugMode = true;
|
|
177
171
|
return this._inDebugMode;
|
|
178
172
|
}
|
|
@@ -187,7 +181,7 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
187
181
|
return log.warn(`Can't identify message from worker: ${JSON.stringify(event)}, ignoring!`);
|
|
188
182
|
}
|
|
189
183
|
if (event.origin === 'worker' && event.name === 'error') {
|
|
190
|
-
return this.log(`[${event.cid}]`,
|
|
184
|
+
return this.log(`[${event.cid}]`, chalk.white.bgRed.bold(' Error: '), event.content.message || event.content.stack || event.content);
|
|
191
185
|
}
|
|
192
186
|
if (event.origin !== 'reporter' && event.origin !== 'debugger') {
|
|
193
187
|
return this.log(event.cid, event.origin, event.name, event.content);
|
|
@@ -224,18 +218,18 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
224
218
|
const reporter = this._messages.reporter;
|
|
225
219
|
this._messages.reporter = {};
|
|
226
220
|
for (const [reporterName, messages] of Object.entries(reporter)) {
|
|
227
|
-
this.log('\n',
|
|
221
|
+
this.log('\n', chalk.bold.magenta(`"${reporterName}" Reporter:`));
|
|
228
222
|
this.log(messages.join(''));
|
|
229
223
|
}
|
|
230
224
|
}
|
|
231
225
|
printSummary() {
|
|
232
226
|
const totalJobs = this.totalWorkerCnt - this.result.retries;
|
|
233
227
|
const elapsed = (new Date(Date.now() - this._start.getTime())).toUTCString().match(/(\d\d:\d\d:\d\d)/)[0];
|
|
234
|
-
const retries = this.result.retries ?
|
|
235
|
-
const failed = this.result.failed ?
|
|
236
|
-
const skipped = this._skippedSpecs > 0 ?
|
|
228
|
+
const retries = this.result.retries ? chalk.yellow(this.result.retries, 'retries') + ', ' : '';
|
|
229
|
+
const failed = this.result.failed ? chalk.red(this.result.failed, 'failed') + ', ' : '';
|
|
230
|
+
const skipped = this._skippedSpecs > 0 ? chalk.gray(this._skippedSpecs, 'skipped') + ', ' : '';
|
|
237
231
|
const percentCompleted = totalJobs ? Math.round(this.result.finished / totalJobs * 100) : 0;
|
|
238
|
-
return this.log('\nSpec Files:\t',
|
|
232
|
+
return this.log('\nSpec Files:\t', chalk.green(this.result.passed, 'passed') + ', ' + retries + failed + skipped + totalJobs, 'total', `(${percentCompleted}% completed)`, 'in', elapsed, '\n');
|
|
239
233
|
}
|
|
240
234
|
finalise() {
|
|
241
235
|
if (this._isWatchMode) {
|
|
@@ -245,4 +239,3 @@ class WDIOCLInterface extends events_1.EventEmitter {
|
|
|
245
239
|
this.printSummary();
|
|
246
240
|
}
|
|
247
241
|
}
|
|
248
|
-
exports.default = WDIOCLInterface;
|