@wdio/cli 8.0.0-alpha.593 → 8.0.0-alpha.600

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.
@@ -5,7 +5,7 @@ export declare const desc = "Initialize WebdriverIO and setup configuration in y
5
5
  export declare const cmdArgs: {
6
6
  readonly yarn: {
7
7
  readonly type: "boolean";
8
- readonly desc: "Install packages via yarn package manager.";
8
+ readonly desc: "Install packages via Yarn package manager.";
9
9
  readonly default: boolean;
10
10
  };
11
11
  readonly yes: {
@@ -14,11 +14,17 @@ export declare const cmdArgs: {
14
14
  readonly type: "boolean";
15
15
  readonly default: false;
16
16
  };
17
+ readonly npmTag: {
18
+ readonly alias: "t";
19
+ readonly desc: "define NPM tag to use for WebdriverIO related packages";
20
+ readonly type: "string";
21
+ readonly default: "latest";
22
+ };
17
23
  };
18
- export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "yarn" | "yes"> & import("yargs").InferredOptionTypes<{
24
+ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "yarn" | "yes" | "npmTag"> & import("yargs").InferredOptionTypes<{
19
25
  readonly yarn: {
20
26
  readonly type: "boolean";
21
- readonly desc: "Install packages via yarn package manager.";
27
+ readonly desc: "Install packages via Yarn package manager.";
22
28
  readonly default: boolean;
23
29
  };
24
30
  readonly yes: {
@@ -27,12 +33,16 @@ export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "ya
27
33
  readonly type: "boolean";
28
34
  readonly default: false;
29
35
  };
36
+ readonly npmTag: {
37
+ readonly alias: "t";
38
+ readonly desc: "define NPM tag to use for WebdriverIO related packages";
39
+ readonly type: "string";
40
+ readonly default: "latest";
41
+ };
30
42
  }>>;
31
- export declare function handler(argv: ConfigCommandArguments): Promise<{
32
- success: boolean;
33
- parsedAnswers?: undefined;
34
- installedPackages?: undefined;
35
- } | {
43
+ export declare const parseAnswers: (yes: boolean) => Promise<ParsedAnswers>;
44
+ export declare function runConfigCommand(parsedAnswers: ParsedAnswers, useYarn: boolean, npmTag: string): Promise<void>;
45
+ export declare function handler(argv: ConfigCommandArguments, runConfigCmd?: typeof runConfigCommand): Promise<{
36
46
  success: boolean;
37
47
  parsedAnswers: ParsedAnswers;
38
48
  installedPackages: string[];
@@ -44,21 +54,5 @@ export declare function handler(argv: ConfigCommandArguments): Promise<{
44
54
  * @param {boolean} useYarn parameter set to true if yarn is used
45
55
  * @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
46
56
  */
47
- export declare function missingConfigurationPrompt(command: string, message: string, useYarn?: boolean, runConfigCmd?: (useYarn: boolean, yes: boolean, exit?: boolean) => Promise<{
48
- success: boolean;
49
- parsedAnswers?: undefined;
50
- installedPackages?: undefined;
51
- } | {
52
- success: boolean;
53
- parsedAnswers: ParsedAnswers;
54
- installedPackages: string[];
55
- }>): Promise<{
56
- success: boolean;
57
- parsedAnswers?: undefined;
58
- installedPackages?: undefined;
59
- } | {
60
- success: boolean;
61
- parsedAnswers: ParsedAnswers;
62
- installedPackages: string[];
63
- }>;
57
+ export declare function missingConfigurationPrompt(command: string, message: string, useYarn?: boolean, runConfigCmd?: typeof runConfigCommand): Promise<false | undefined>;
64
58
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAajC,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAErE,eAAO,MAAM,OAAO,WAAW,CAAA;AAC/B,eAAO,MAAM,IAAI,4EAA4E,CAAA;AAE7F,eAAO,MAAM,OAAO;;;;;;;;;;;;CAYV,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI;;;;;;;;;;;;GAKlC,CAAA;AA0MD,wBAAgB,OAAO,CAAC,IAAI,EAAE,sBAAsB;;;;;;;;GAEnD;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,UAAQ,EAAE,YAAY;;;;;;;;EAAY;;;;;;;;GA4B3H"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAQjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAIrE,eAAO,MAAM,OAAO,WAAW,CAAA;AAC/B,eAAO,MAAM,IAAI,4EAA4E,CAAA;AAE7F,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;CAkBV,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI;;;;;;;;;;;;;;;;;;GAKlC,CAAA;AAED,eAAO,MAAM,YAAY,QAAwB,OAAO,KAAG,QAAQ,aAAa,CAgF/E,CAAA;AAED,wBAAsB,gBAAgB,CAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAkBrG;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,sBAAsB,EAAE,YAAY,0BAAmB;;;;GAQ1F;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,UAAQ,EAAE,YAAY,0BAAmB,8BA2BlI"}
@@ -2,22 +2,28 @@ import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import util from 'node:util';
4
4
  import inquirer from 'inquirer';
5
- import yarnInstall from 'yarn-install';
6
- import { CONFIG_HELPER_INTRO, CLI_EPILOGUE, COMPILER_OPTIONS, CONFIG_HELPER_SUCCESS_MESSAGE, TESTING_LIBRARY_PACKAGES, DEPENDENCIES_INSTALLATION_MESSAGE, SUPPORTED_PACKAGES, pkg } from '../constants.js';
7
- import { addServiceDeps, convertPackageHashToObject, renderConfigurationFile, hasFile, generateTestFiles, getAnswers, getPathForFileGeneration, hasPackage, specifyVersionIfNeeded } from '../utils.js';
5
+ import { CONFIG_HELPER_INTRO, CLI_EPILOGUE, COMPILER_OPTIONS, SUPPORTED_PACKAGES, CONFIG_HELPER_SUCCESS_MESSAGE } from '../constants.js';
6
+ import { convertPackageHashToObject, getAnswers, getPathForFileGeneration, getProjectProps, getProjectRoot, createPackageJSON, setupTypeScript, setupBabel, npmInstall, createWDIOConfig, createWDIOScript } from '../utils.js';
7
+ const hasYarnLock = await fs.access('yarn.lock').then(() => true, () => false);
8
8
  export const command = 'config';
9
9
  export const desc = 'Initialize WebdriverIO and setup configuration in your current project.';
10
10
  export const cmdArgs = {
11
11
  yarn: {
12
12
  type: 'boolean',
13
- desc: 'Install packages via yarn package manager.',
14
- default: hasFile('yarn.lock')
13
+ desc: 'Install packages via Yarn package manager.',
14
+ default: hasYarnLock
15
15
  },
16
16
  yes: {
17
17
  alias: 'y',
18
18
  desc: 'will fill in all config defaults without prompting',
19
19
  type: 'boolean',
20
20
  default: false
21
+ },
22
+ npmTag: {
23
+ alias: 't',
24
+ desc: 'define NPM tag to use for WebdriverIO related packages',
25
+ type: 'string',
26
+ default: 'latest'
21
27
  }
22
28
  };
23
29
  export const builder = (yargs) => {
@@ -26,7 +32,7 @@ export const builder = (yargs) => {
26
32
  .epilogue(CLI_EPILOGUE)
27
33
  .help();
28
34
  };
29
- const runConfig = async function (useYarn, yes, exit = false) {
35
+ export const parseAnswers = async function (yes) {
30
36
  console.log(CONFIG_HELPER_INTRO);
31
37
  const answers = await getAnswers(yes);
32
38
  const frameworkPackage = convertPackageHashToObject(answers.framework);
@@ -35,6 +41,8 @@ const runConfig = async function (useYarn, yes, exit = false) {
35
41
  const pluginPackages = answers.plugins.map((plugin) => convertPackageHashToObject(plugin));
36
42
  const reporterPackages = answers.reporters.map((reporter) => convertPackageHashToObject(reporter));
37
43
  const presetPackage = convertPackageHashToObject(answers.preset || '');
44
+ const projectProps = await getProjectProps(process.cwd());
45
+ const projectRootDir = getProjectRoot(answers, projectProps);
38
46
  let packagesToInstall = [
39
47
  runnerPackage.package,
40
48
  frameworkPackage.package,
@@ -46,156 +54,80 @@ const runConfig = async function (useYarn, yes, exit = false) {
46
54
  /**
47
55
  * find relative paths between tests and pages
48
56
  */
49
- const parsedPaths = getPathForFileGeneration(answers);
50
- const parsedAnswers = {
57
+ const hasRootTSConfig = await fs.access(path.resolve(projectRootDir, 'tsconfig.json')).then(() => true, () => false);
58
+ const tsConfigFilePath = !hasRootTSConfig
59
+ /**
60
+ * if no tsconfig.json exists in project, create one
61
+ */
62
+ ? path.resolve(projectRootDir, 'tsconfig.json')
63
+ /**
64
+ * otherwise make it dependant whether user wants to autogenerate files
65
+ */
66
+ : answers.specs
67
+ /**
68
+ * if we have autogenerated spec files, put the tsconfig one above the spec file dir
69
+ */
70
+ ? path.resolve(path.dirname(answers.specs.split('/').filter((s) => !s.includes('*')).join('/')), 'tsconfig.json')
71
+ /**
72
+ * if no spec files are auto generated, create a wdio tsconfig and let the user deal with it
73
+ */
74
+ : path.resolve(projectRootDir, `tsconfig.${runnerPackage.short === 'local' ? 'e2e' : 'wdio'}.json`);
75
+ const parsedPaths = getPathForFileGeneration(answers, projectRootDir);
76
+ const isUsingTypeScript = answers.isUsingCompiler === COMPILER_OPTIONS.ts;
77
+ const wdioConfigFilename = `wdio.conf.${isUsingTypeScript ? 'ts' : 'js'}`;
78
+ const wdioConfigPath = path.resolve(projectRootDir, wdioConfigFilename);
79
+ return {
51
80
  // default values required in templates
52
81
  ...({
53
82
  usePageObjects: false,
54
83
  installTestingLibrary: false
55
84
  }),
56
85
  ...answers,
86
+ rawAnswers: answers,
57
87
  runner: runnerPackage.short,
58
88
  preset: presetPackage.short,
59
89
  framework: frameworkPackage.short,
60
90
  reporters: reporterPackages.map(({ short }) => short),
61
91
  plugins: pluginPackages.map(({ short }) => short),
62
92
  services: servicePackages.map(({ short }) => short),
93
+ specs: answers.specs && `.${answers.specs.replace(projectRootDir, '')}`,
63
94
  packagesToInstall,
64
- isUsingTypeScript: answers.isUsingCompiler === COMPILER_OPTIONS.ts,
95
+ isUsingTypeScript,
65
96
  isUsingBabel: answers.isUsingCompiler === COMPILER_OPTIONS.babel,
97
+ esmSupport: projectProps?.esmSupported || answers.moduleSystem === 'esm' || answers.isUsingCompiler === COMPILER_OPTIONS.babel,
66
98
  isSync: false,
67
99
  _async: 'async ',
68
100
  _await: 'await ',
101
+ projectRootDir,
69
102
  destSpecRootPath: parsedPaths.destSpecRootPath,
70
103
  destPageObjectRootPath: parsedPaths.destPageObjectRootPath,
71
104
  relativePath: parsedPaths.relativePath,
72
- tsConfigFilePath: path.join(process.cwd(), 'test', 'tsconfig.json')
105
+ tsConfigFilePath,
106
+ tsProject: `.${tsConfigFilePath.replace(projectRootDir, '')}`,
107
+ wdioConfigPath
73
108
  };
109
+ };
110
+ export async function runConfigCommand(parsedAnswers, useYarn, npmTag) {
111
+ console.log('\n');
112
+ await createPackageJSON(parsedAnswers);
113
+ await setupTypeScript(parsedAnswers);
114
+ await setupBabel(parsedAnswers);
115
+ await npmInstall(parsedAnswers, useYarn, npmTag);
116
+ await createWDIOConfig(parsedAnswers);
117
+ await createWDIOScript(parsedAnswers);
74
118
  /**
75
- * add ts-node if TypeScript is desired but not installed
76
- */
77
- if (parsedAnswers.isUsingTypeScript) {
78
- if (!await hasPackage('ts-node')) {
79
- packagesToInstall.push('ts-node', 'typescript');
80
- }
81
- const types = [
82
- 'node',
83
- '@wdio/globals/types',
84
- 'expect-webdriverio',
85
- frameworkPackage.package,
86
- ...(parsedAnswers.runner === 'browser' ? ['@wdio/browser-runner'] : []),
87
- ...servicePackages
88
- .map(service => service.package)
89
- /**
90
- * given that we know that all "offical" services have
91
- * typescript support we only include them
92
- */
93
- .filter(service => service.startsWith('@wdio'))
94
- ];
95
- const config = {
96
- compilerOptions: {
97
- moduleResolution: 'node',
98
- types,
99
- target: 'es2022',
100
- }
101
- };
102
- await fs.mkdir(path.join(process.cwd(), 'test'), { recursive: true });
103
- await fs.writeFile(parsedAnswers.tsConfigFilePath, JSON.stringify(config, null, 4));
104
- }
105
- /**
106
- * install Testing Library dependency if desired
107
- */
108
- if (answers.installTestingLibrary) {
109
- packagesToInstall.push(TESTING_LIBRARY_PACKAGES[presetPackage.short], '@testing-library/jest-dom');
110
- }
111
- /**
112
- * add @babel/register package if not installed
113
- */
114
- if (parsedAnswers.isUsingBabel) {
115
- if (!await hasPackage('@babel/register')) {
116
- packagesToInstall.push('@babel/register');
117
- }
118
- /**
119
- * setup Babel if no config file exists
120
- */
121
- if (!hasFile('babel.config.js')) {
122
- if (!await hasPackage('@babel/core')) {
123
- packagesToInstall.push('@babel/core');
124
- }
125
- if (!await hasPackage('@babel/preset-env')) {
126
- packagesToInstall.push('@babel/preset-env');
127
- }
128
- await fs.writeFile(path.join(process.cwd(), 'babel.config.js'), `module.exports = ${JSON.stringify({
129
- presets: [
130
- ['@babel/preset-env', {
131
- targets: {
132
- node: '14'
133
- }
134
- }]
135
- ]
136
- }, null, 4)}`);
137
- }
138
- }
139
- /**
140
- * add packages that are required by services
141
- */
142
- addServiceDeps(servicePackages, packagesToInstall);
143
- /**
144
- * update package version if CLI is a pre release
145
- */
146
- packagesToInstall = specifyVersionIfNeeded(packagesToInstall, pkg.version);
147
- /**
148
- * run npm install only if required by the user
149
- */
150
- if (parsedAnswers.npmInstall) {
151
- console.log('\nInstalling wdio packages:\n-', packagesToInstall.join('\n- '));
152
- const result = yarnInstall({ deps: packagesToInstall, dev: true, respectNpm5: !useYarn });
153
- if (result.status !== 0) {
154
- const customError = 'An unknown error happened! Please retry ' +
155
- `installing dependencies via "${useYarn ? 'yarn add --dev' : 'npm i --save-dev'} ` +
156
- `${packagesToInstall.join(' ')}"\n\nError: ${result.stderr || 'unknown'}`;
157
- console.log(customError);
158
- /**
159
- * don't exit if running unit tests
160
- */
161
- if (exit /* istanbul ignore next */ && !process.env.VITEST_WORKER_ID) {
162
- /* istanbul ignore next */
163
- process.exit(1);
164
- }
165
- return { success: false };
166
- }
167
- console.log('\nPackages installed successfully, creating configuration file...');
168
- }
169
- else {
170
- const installationCommand = `${useYarn ? 'yarn add --dev' : 'npm i --save-dev'} ${packagesToInstall.join(' ')}`;
171
- console.log(util.format(DEPENDENCIES_INSTALLATION_MESSAGE, installationCommand));
172
- }
173
- try {
174
- await renderConfigurationFile(parsedAnswers);
175
- if (answers.generateTestFiles) {
176
- console.log('\nConfig file installed successfully, creating test files...');
177
- await generateTestFiles(parsedAnswers);
178
- }
179
- }
180
- catch (err) {
181
- throw new Error(`Couldn't write config file: ${err.stack}`);
182
- }
183
- console.log(util.format(CONFIG_HELPER_SUCCESS_MESSAGE, parsedAnswers.isUsingTypeScript ? 'test/' : '', parsedAnswers.isUsingTypeScript ? 'ts' : 'js'));
184
- /**
185
- * don't exit if running unit tests
119
+ * print success message
186
120
  */
187
- if (exit /* istanbul ignore next */ && !process.env.VITEST_WORKER_ID) {
188
- /* istanbul ignore next */
189
- process.exit(0);
190
- }
121
+ console.log(util.format(CONFIG_HELPER_SUCCESS_MESSAGE, parsedAnswers.projectRootDir, parsedAnswers.projectRootDir));
122
+ }
123
+ export async function handler(argv, runConfigCmd = runConfigCommand) {
124
+ const parsedAnswers = await parseAnswers(argv.yes);
125
+ await runConfigCmd(parsedAnswers, argv.yarn, argv.npmTag);
191
126
  return {
192
127
  success: true,
193
128
  parsedAnswers,
194
- installedPackages: packagesToInstall.map((pkg) => pkg.split('--')[0])
129
+ installedPackages: parsedAnswers.packagesToInstall.map((pkg) => pkg.split('--')[0])
195
130
  };
196
- };
197
- export function handler(argv) {
198
- return runConfig(argv.yarn, argv.yes);
199
131
  }
200
132
  /**
201
133
  * Helper utility used in `run` and `install` command to create config if none exist
@@ -204,28 +136,27 @@ export function handler(argv) {
204
136
  * @param {boolean} useYarn parameter set to true if yarn is used
205
137
  * @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
206
138
  */
207
- export async function missingConfigurationPrompt(command, message, useYarn = false, runConfigCmd = runConfig) {
139
+ export async function missingConfigurationPrompt(command, message, useYarn = false, runConfigCmd = runConfigCommand) {
208
140
  const configMessage = command === 'run'
209
141
  ? `Error: Could not execute "run" due to missing configuration, file "${message}" not found! Would you like to create one?`
210
142
  : `Error: Could not execute "${command}" due to missing configuration. Would you like to create one?`;
211
- const { config } = await inquirer.prompt([
212
- {
143
+ const { config } = await inquirer.prompt([{
213
144
  type: 'confirm',
214
145
  name: 'config',
215
146
  message: configMessage,
216
147
  default: false
217
- }
218
- ]);
148
+ }]);
219
149
  /**
220
150
  * don't exit if running unit tests
221
151
  */
222
- if (!config && !process.env.VITEST_WORKER_ID) {
152
+ if (!config) {
223
153
  /* istanbul ignore next */
224
154
  console.log(command === 'run'
225
155
  ? `No WebdriverIO configuration found in "${process.cwd()}"`
226
156
  : message);
227
157
  /* istanbul ignore next */
228
- return process.exit(0);
158
+ return !process.env.VITEST_WORKER_ID && process.exit(0);
229
159
  }
230
- return await runConfigCmd(useYarn, false, true);
160
+ const parsedAnswers = await parseAnswers(false);
161
+ await runConfigCmd(parsedAnswers, useYarn, 'latest');
231
162
  }
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAUjC,OAAO,KAAK,EAAE,uBAAuB,EAAoB,MAAM,UAAU,CAAA;AAUzE,eAAO,MAAM,OAAO,0BAA0B,CAAA;AAC9C,eAAO,MAAM,IAAI,QAIN,CAAA;AAEX,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI,aAalC,CAAA;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,uBAAuB,iBA0E1D"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAUjC,OAAO,KAAK,EAAE,uBAAuB,EAAoB,MAAM,UAAU,CAAA;AAUzE,eAAO,MAAM,OAAO,0BAA0B,CAAA;AAC9C,eAAO,MAAM,IAAI,QAIN,CAAA;AAEX,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV,eAAO,MAAM,OAAO,UAAW,IAAI,aAalC,CAAA;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,uBAAuB,iBA2E1D"}
@@ -68,8 +68,8 @@ export async function handler(argv) {
68
68
  const localConfExists = await fs.access(localConfPath).then(() => true, () => false);
69
69
  if (!localConfExists) {
70
70
  try {
71
- const promptMessage = `Cannot install packages without a WebdriverIO configuration.
72
- You can create one by running 'wdio config'`;
71
+ const promptMessage = ('Cannot install packages without a WebdriverIO configuration. ' +
72
+ 'You can create one by running \'wdio config\'');
73
73
  await missingConfigurationPrompt('install', promptMessage, yarn);
74
74
  }
75
75
  catch {
@@ -8,7 +8,7 @@ export declare const EXCLUSIVE_SERVICES: {
8
8
  };
9
9
  };
10
10
  export declare const CONFIG_HELPER_INTRO = "\n=========================\nWDIO Configuration Helper\n=========================\n";
11
- export declare const CONFIG_HELPER_SUCCESS_MESSAGE = "\nConfiguration file was created successfully!\nTo run your tests, execute:\n$ npx wdio run %swdio.conf.%s\n";
11
+ export declare const CONFIG_HELPER_SUCCESS_MESSAGE = "\n\uD83E\uDD16 Successfully setup project at %s \uD83C\uDF89\n\nJoin our Gitter community and instantly find answers to your issues or queries. Or just join and say hi \uD83D\uDC4B!\n \uD83D\uDD17 https://gitter.im/webdriverio/webdriverio\n\nVisit the project on GitHub to report bugs \uD83D\uDC1B or raise feature requests \uD83D\uDCA1:\n \uD83D\uDD17 https://github.com/webdriverio/webdriverio\n\nTo run your tests, execute:\n$ cd %s\n$ npm run wdio\n";
12
12
  export declare const DEPENDENCIES_INSTALLATION_MESSAGE = "\nTo install dependencies, execute:\n%s\n";
13
13
  export declare const NPM_INSTALL = "";
14
14
  export declare const ANDROID_CONFIG: {
@@ -305,14 +305,6 @@ export declare const QUESTIONNAIRE: ({
305
305
  choices: readonly ["https", "http"];
306
306
  when: (answers: Questionnair) => boolean;
307
307
  validate?: undefined;
308
- } | {
309
- type: string;
310
- name: string;
311
- message: string;
312
- default: boolean;
313
- when: (answers: Questionnair) => boolean;
314
- choices?: undefined;
315
- validate?: undefined;
316
308
  } | {
317
309
  type: string;
318
310
  name: string;
@@ -352,23 +344,23 @@ export declare const QUESTIONNAIRE: ({
352
344
  name: string;
353
345
  message: string;
354
346
  choices: readonly ["Babel (https://babeljs.io/)", "TypeScript (https://www.typescriptlang.org/)", "No!"];
355
- default: () => "Babel (https://babeljs.io/)" | "TypeScript (https://www.typescriptlang.org/)" | "No!";
347
+ default: (answers: Questionnair) => Promise<"Babel (https://babeljs.io/)" | "TypeScript (https://www.typescriptlang.org/)" | "No!">;
356
348
  when?: undefined;
357
349
  validate?: undefined;
358
350
  } | {
359
351
  type: string;
360
352
  name: string;
361
353
  message: string;
362
- default: (answers: Questionnair) => string;
363
- when: (answers: Questionnair) => RegExpMatchArray | null;
354
+ default: boolean;
364
355
  choices?: undefined;
356
+ when?: undefined;
365
357
  validate?: undefined;
366
358
  } | {
367
359
  type: string;
368
360
  name: string;
369
361
  message: string;
370
- default: (answers: Questionnair) => string;
371
- when: (answers: Questionnair) => boolean;
362
+ default: (answers: Questionnair) => Promise<string>;
363
+ when: (answers: Questionnair) => false | RegExpMatchArray | null;
372
364
  choices?: undefined;
373
365
  validate?: undefined;
374
366
  } | {
@@ -376,8 +368,16 @@ export declare const QUESTIONNAIRE: ({
376
368
  name: string;
377
369
  message: string;
378
370
  default: boolean;
371
+ when: (answers: Questionnair) => boolean;
372
+ choices?: undefined;
373
+ validate?: undefined;
374
+ } | {
375
+ type: string;
376
+ name: string;
377
+ message: string;
378
+ default: (answers: Questionnair) => Promise<string>;
379
+ when: (answers: Questionnair) => boolean | undefined;
379
380
  choices?: undefined;
380
- when?: undefined;
381
381
  validate?: undefined;
382
382
  } | {
383
383
  type: string;
@@ -1 +1 @@
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;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFrB,CAAA;AAEV,eAAO,MAAM,kCAAkC,UAG9C,CAAA;AAED,eAAO,MAAM,gCAAgC;;;GAQ5C,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAK3D,CAAA;AAED,eAAO,MAAM,eAAe,0NAMlB,CAAA;AAEV,eAAO,MAAM,gBAAgB,4BAGnB,CAAA;AAEV,eAAO,MAAM,aAAa,+BAIhB,CAAA;AAEV,iBA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D,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'node:module';
2
- import { validateServiceAnswers, hasFile, getDefaultFiles, convertPackageHashToObject } from './utils.js';
2
+ import { validateServiceAnswers, detectCompiler, getDefaultFiles, convertPackageHashToObject } from './utils.js';
3
3
  const require = createRequire(import.meta.url);
4
4
  export const pkg = require('../package.json');
5
5
  export const CLI_EPILOGUE = `Documentation: https://webdriver.io\n@wdio/cli (v${pkg.version})`;
@@ -15,9 +15,17 @@ WDIO Configuration Helper
15
15
  =========================
16
16
  `;
17
17
  export const CONFIG_HELPER_SUCCESS_MESSAGE = `
18
- Configuration file was created successfully!
18
+ 🤖 Successfully setup project at %s 🎉
19
+
20
+ Join our Gitter community and instantly find answers to your issues or queries. Or just join and say hi 👋!
21
+ 🔗 https://gitter.im/webdriverio/webdriverio
22
+
23
+ Visit the project on GitHub to report bugs 🐛 or raise feature requests 💡:
24
+ 🔗 https://github.com/webdriverio/webdriverio
25
+
19
26
  To run your tests, execute:
20
- $ npx wdio run %swdio.conf.%s
27
+ $ cd %s
28
+ $ npm run wdio
21
29
  `;
22
30
  export const DEPENDENCIES_INSTALLATION_MESSAGE = `
23
31
  To install dependencies, execute:
@@ -282,18 +290,12 @@ export const QUESTIONNAIRE = [{
282
290
  message: 'Environment variable for access key',
283
291
  default: 'SAUCE_ACCESS_KEY',
284
292
  when: /* istanbul ignore next */ (answers) => answers.backend === 'In the cloud using Sauce Labs'
285
- }, {
286
- type: 'confirm',
287
- name: 'headless',
288
- message: 'Do you want to run your test on Sauce Headless? (https://saucelabs.com/products/web-testing/sauce-headless)',
289
- default: false,
290
- when: /* istanbul ignore next */ (answers) => answers.backend === 'In the cloud using Sauce Labs'
291
293
  }, {
292
294
  type: 'list',
293
295
  name: 'region',
294
296
  message: 'In which region do you want to run your Sauce Labs tests in?',
295
297
  choices: REGION_OPTION,
296
- when: /* istanbul ignore next */ (answers) => !answers.headless && answers.backend === 'In the cloud using Sauce Labs'
298
+ when: /* istanbul ignore next */ (answers) => answers.backend === 'In the cloud using Sauce Labs'
297
299
  }, {
298
300
  type: 'input',
299
301
  name: 'hostname',
@@ -330,34 +332,30 @@ export const QUESTIONNAIRE = [{
330
332
  name: 'isUsingCompiler',
331
333
  message: 'Do you want to use a compiler?',
332
334
  choices: COMPILER_OPTION_ANSWERS,
333
- default: /* istanbul ignore next */ () => hasFile('babel.config.js')
334
- ? COMPILER_OPTIONS.babel // default to Babel
335
- : hasFile('tsconfig.json')
336
- ? COMPILER_OPTIONS.ts // default to TypeScript
337
- : COMPILER_OPTIONS.nil // default to no compiler
335
+ default: /* istanbul ignore next */ (answers) => detectCompiler(answers)
336
+ }, {
337
+ type: 'confirm',
338
+ name: 'generateTestFiles',
339
+ message: 'Do you want WebdriverIO to autogenerate some test files?',
340
+ default: true
338
341
  }, {
339
342
  type: 'input',
340
343
  name: 'specs',
341
- message: 'Where are your test specs located?',
342
- default: (answers) => getDefaultFiles(answers, './test/specs/**/*'),
343
- when: /* istanbul ignore next */ (answers) => answers.framework.match(/(mocha|jasmine)/)
344
+ message: 'Where should these files be located?',
345
+ default: /* istanbul ignore next */ (answers) => getDefaultFiles(answers, 'test/specs/**/*'),
346
+ when: /* istanbul ignore next */ (answers) => answers.generateTestFiles && answers.framework.match(/(mocha|jasmine)/)
344
347
  }, {
345
348
  type: 'input',
346
349
  name: 'specs',
347
- message: 'Where are your feature files located?',
348
- default: './features/**/*.feature',
349
- when: /* istanbul ignore next */ (answers) => answers.framework.includes('cucumber')
350
+ message: 'Where should these feature files be located?',
351
+ default: (answers) => getDefaultFiles(answers, 'features/**/*.feature'),
352
+ when: /* istanbul ignore next */ (answers) => answers.generateTestFiles && answers.framework.includes('cucumber')
350
353
  }, {
351
354
  type: 'input',
352
355
  name: 'stepDefinitions',
353
- message: 'Where are your step definitions located?',
354
- default: (answers) => getDefaultFiles(answers, './features/step-definitions/steps'),
355
- when: /* istanbul ignore next */ (answers) => answers.framework.includes('cucumber')
356
- }, {
357
- type: 'confirm',
358
- name: 'generateTestFiles',
359
- message: 'Do you want WebdriverIO to autogenerate some test files?',
360
- default: true
356
+ message: 'Where should these step definitions be located?',
357
+ default: (answers) => getDefaultFiles(answers, 'features/step-definitions/steps'),
358
+ when: /* istanbul ignore next */ (answers) => answers.generateTestFiles && answers.framework.includes('cucumber')
361
359
  }, {
362
360
  type: 'confirm',
363
361
  name: 'usePageObjects',
@@ -373,8 +371,8 @@ export const QUESTIONNAIRE = [{
373
371
  name: 'pages',
374
372
  message: 'Where are your page objects located?',
375
373
  default: /* istanbul ignore next */ (answers) => (answers.framework.match(/(mocha|jasmine)/)
376
- ? getDefaultFiles(answers, './test/pageobjects/**/*')
377
- : getDefaultFiles(answers, './features/pageobjects/**/*')),
374
+ ? getDefaultFiles(answers, 'test/pageobjects/**/*')
375
+ : getDefaultFiles(answers, 'features/pageobjects/**/*')),
378
376
  when: /* istanbul ignore next */ (answers) => answers.generateTestFiles && answers.usePageObjects
379
377
  }, {
380
378
  type: 'checkbox',
@@ -1,4 +1,4 @@
1
- <%- isUsingTypeScript || isUsingBabel
1
+ <%- isUsingTypeScript || esmSupport
2
2
  ? "import { Given, When, Then } from '@wdio/cucumber-framework';"
3
3
  : "const { Given, When, Then } = require('@wdio/cucumber-framework');" %>
4
4
  <%
@@ -6,11 +6,11 @@
6
6
  * step definition without page objects
7
7
  */
8
8
  if (usePageObjects) { %>
9
- <%- isUsingTypeScript || isUsingBabel
10
- ? `import LoginPage from '${relativePath}/login.page';`
9
+ <%- isUsingTypeScript || esmSupport
10
+ ? `import LoginPage from '${relativePath}/login.page${esmSupport ? '.js' : ''}';`
11
11
  : `const LoginPage = require('${relativePath}/login.page');` %>
12
- <%- isUsingTypeScript || isUsingBabel
13
- ? `import SecurePage from '${relativePath}/secure.page';`
12
+ <%- isUsingTypeScript || esmSupport
13
+ ? `import SecurePage from '${relativePath}/secure.page${esmSupport ? '.js' : ''}';`
14
14
  : `const SecurePage = require('${relativePath}/secure.page');` %>
15
15
 
16
16
  const pages = {
@@ -3,11 +3,11 @@
3
3
  * step definition without page objects
4
4
  */
5
5
  if (usePageObjects) {
6
- %><%- isUsingTypeScript || isUsingBabel
7
- ? `import LoginPage from '${relativePath}/login.page';`
6
+ %><%- isUsingTypeScript || esmSupport
7
+ ? `import LoginPage from '${relativePath}/login.page${esmSupport ? '.js' : ''}';`
8
8
  : `const LoginPage = require('${relativePath}/login.page');` %>
9
- <%- isUsingTypeScript || isUsingBabel
10
- ? `import SecurePage from '${relativePath}/secure.page';`
9
+ <%- isUsingTypeScript || esmSupport
10
+ ? `import SecurePage from '${relativePath}/secure.page${esmSupport ? '.js' : ''}';`
11
11
  : `const SecurePage = require('${relativePath}/secure.page');` %>
12
12
 
13
13
  describe('My Login application', () => {
@@ -3,11 +3,11 @@
3
3
  * test with page objects
4
4
  */
5
5
  if (usePageObjects) {
6
- %><%- isUsingTypeScript || isUsingBabel
7
- ? `import LoginPage from '${relativePath}/login.page'`
6
+ %><%- isUsingTypeScript || esmSupport
7
+ ? `import LoginPage from '${relativePath}/login.page${esmSupport ? '.js' : ''}'`
8
8
  : `const LoginPage = require('${relativePath}/login.page')` %>
9
- <%- isUsingTypeScript || isUsingBabel
10
- ? `import SecurePage from '${relativePath}/secure.page'`
9
+ <%- isUsingTypeScript || esmSupport
10
+ ? `import SecurePage from '${relativePath}/secure.page${esmSupport ? '.js' : ''}'`
11
11
  : `const SecurePage = require('${relativePath}/secure.page')` %>
12
12
 
13
13
  describe('My Login application', () => {
@@ -57,6 +57,7 @@ const assertionStatement = preset
57
57
  import * as matchers from '@testing-library/jest-dom/matchers'
58
58
  expect.extend(matchers)
59
59
  <% } %>
60
+ // ToDo: fix me
60
61
  <%- importStatement %>
61
62
 
62
63
  describe('<%- (preset || 'my') %> component tests', () => {