MCPcopy Create free account
hub / github.com/webdriverio/webdriverio / missingConfigurationPrompt

Function missingConfigurationPrompt

packages/create-wdio/src/cli/utils.ts:47–78  ·  view source on GitHub ↗
(command: string, configPath: string, runConfigCmd: Function = runConfigCommand)

Source from the content-addressed store, hash-verified

45 * @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
46 */
47export async function missingConfigurationPrompt(command: string, configPath: string, runConfigCmd: Function = runConfigCommand) {
48 const message = (
49 `Could not execute "${command}" due to missing configuration, file ` +
50 `"${path.parse(configPath).name}[.js/.ts]" not found! ` +
51 'Would you like to create one?'
52 )
53
54 const { config } = await inquirer.prompt({
55 type: 'confirm',
56 name: 'config',
57 message,
58 default: false
59 })
60
61 /**
62 * don't exit if running unit tests
63 */
64 if (!config) {
65 /* istanbul ignore next */
66 console.log(`No WebdriverIO configuration found in "${process.cwd()}"`)
67
68 /* istanbul ignore next */
69 if (!process.env.WDIO_UNIT_TESTS) {
70 process.exit(0)
71 }
72 return configPath
73 }
74
75 const parsedAnswers = await parseAnswers(false)
76 await runConfigCmd(parsedAnswers, 'latest')
77 return configPath
78}
79
80export const parseAnswers = async function (yes: boolean): Promise<ParsedAnswers> {
81 console.log(CONFIG_HELPER_INTRO)

Callers 2

handlerFunction · 0.85
utils.test.tsFile · 0.85

Calls 2

parseAnswersFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…