create-wdio 9.32.0-alpha.6 → 10.0.0-alpha.148
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/AGENTS.md +40 -0
- package/README.md +8 -0
- package/build/answerFlags.d.ts +68 -0
- package/build/answerFlags.d.ts.map +1 -0
- package/build/cli/agent.d.ts +17 -0
- package/build/cli/agent.d.ts.map +1 -0
- package/build/cli/config.d.ts +4 -4
- package/build/cli/config.d.ts.map +1 -1
- package/build/cli/utils.d.ts +15 -3
- package/build/cli/utils.d.ts.map +1 -1
- package/build/config/cli.js +660 -77
- package/build/constants.d.ts +25 -1
- package/build/constants.d.ts.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +416 -18
- package/build/install/cli.js +597 -80
- package/build/templates/snippets/capabilities.ejs +7 -0
- package/build/templates/snippets/cucumber.ejs +1 -1
- package/build/templates/snippets/services.ejs +22 -0
- package/build/templates/wdio.conf.tpl.ejs +4 -0
- package/build/types.d.ts +13 -3
- package/build/types.d.ts.map +1 -1
- package/build/utils/index.js +305 -12
- package/build/utils.d.ts +16 -4
- package/build/utils.d.ts.map +1 -1
- package/package.json +5 -6
- package/templates/wdio-session/SKILL.md +96 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# create-wdio
|
|
2
|
+
|
|
3
|
+
Scaffolds a WebdriverIO project (`npm create wdio` / `npm init wdio`) and the
|
|
4
|
+
`wdio config` / `wdio install` commands re-exported to `@wdio/cli`.
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
pnpm run dev create-wdio
|
|
10
|
+
pnpm run test:package create-wdio
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Tests
|
|
14
|
+
|
|
15
|
+
Unit tests import `src/` directly. They do not prove a generated project runs;
|
|
16
|
+
that is a smoke or example run.
|
|
17
|
+
|
|
18
|
+
- `answers.generateTestFiles` is enforced in `createWDIOConfig` before it calls
|
|
19
|
+
`generateTestFiles`. The generator itself always renders the selected
|
|
20
|
+
framework templates. An empty directory listing does not prove generation
|
|
21
|
+
was skipped.
|
|
22
|
+
- `getPackageVersion` reads this package's `package.json` and falls back to
|
|
23
|
+
`'unknown'`. Assert the version string. `expect.any(String)` also passes on
|
|
24
|
+
the fallback, which is what a `fs/promises` mock without `readFile` produces.
|
|
25
|
+
- `createWDIOScript` shells out through `runProgram`. The call is owned by the
|
|
26
|
+
`runConfigCommand` test. Do not assert `child_process.spawn` for it.
|
|
27
|
+
- Lit component templates ignore `installTestingLibrary`. A lit case named for
|
|
28
|
+
the absence of Testing Library must pass `installTestingLibrary: false`.
|
|
29
|
+
- Declining the missing-config prompt exits the process. Mock `process.exit`
|
|
30
|
+
so that it throws; a non-throwing mock falls through into the wizard.
|
|
31
|
+
|
|
32
|
+
## Wizard flags
|
|
33
|
+
|
|
34
|
+
`src/answerFlags.ts` maps a command line flag to every `QUESTIONNAIRE`
|
|
35
|
+
question. `npm init wdio` (commander) and `wdio config` (yargs) both read it,
|
|
36
|
+
and `npm init wdio` forwards the flags to `wdio config`. When you add or
|
|
37
|
+
rename a question or a choice, update its entry and the flag table in
|
|
38
|
+
`website/docs/GettingStarted.md`. A flag for a question whose `when` is false,
|
|
39
|
+
or a value outside its `choices`, is rejected after the answers are collected
|
|
40
|
+
(`assertAnswerFlagsApply`).
|
package/README.md
CHANGED
|
@@ -64,6 +64,14 @@ You can pass the following command line flags to modify the bootstrap mechanism:
|
|
|
64
64
|
* `--yes` - Will fill in all config defaults without prompting (default: `false`)
|
|
65
65
|
* `--npm-tag` - use a specific NPM tag for `@wdio/cli` package (default: `latest`)
|
|
66
66
|
|
|
67
|
+
Every question of the configuration wizard also has a flag, e.g. `--runner`, `--framework`, `--typescript`, `--browsers`, `--reporters` or `--services`. A flag answers its question and the wizard only asks the rest. Combined with `--yes` the setup runs without any prompt, e.g. for a coding agent or a CI job:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
npm init wdio@latest ./e2e -- --yes --framework cucumber --no-typescript --reporters spec,junit
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Run `npm init wdio@latest -- --help` for every flag and the values it accepts. Boolean flags take a `--no-` prefix. An invalid value, or a flag for a question that does not apply to your setup, exits with code 2.
|
|
74
|
+
|
|
67
75
|
----
|
|
68
76
|
|
|
69
77
|
For more information on WebdriverIO see the [homepage](https://webdriver.io).
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Questionnair } from './types.js';
|
|
2
|
+
type AnswerValue = string | null;
|
|
3
|
+
export interface AnswerFlag {
|
|
4
|
+
/**
|
|
5
|
+
* camelCase option name, passed as `--kebab-case` on the command line
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
answer: keyof Questionnair;
|
|
9
|
+
type: 'string' | 'boolean' | 'array';
|
|
10
|
+
desc: string;
|
|
11
|
+
/**
|
|
12
|
+
* CLI value → wizard answer value
|
|
13
|
+
*/
|
|
14
|
+
choices?: () => Record<string, AnswerValue>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Thrown for a flag value the wizard cannot use. The CLI prints the message
|
|
18
|
+
* and exits with code 2, like any other usage error.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AnswerFlagError extends Error {
|
|
21
|
+
name: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Every wizard question that can be answered from the command line.
|
|
25
|
+
* `npm init wdio` and `wdio config` both read this list, so the flags and
|
|
26
|
+
* their help text stay the same in both commands.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ANSWER_FLAGS: AnswerFlag[];
|
|
29
|
+
/**
|
|
30
|
+
* Help text for one flag, with the accepted values if it has a fixed set.
|
|
31
|
+
*/
|
|
32
|
+
export declare function describeAnswerFlag(flag: AnswerFlag): string;
|
|
33
|
+
/**
|
|
34
|
+
* Shared by the `--help` output of `npm init wdio` and `wdio config`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const ANSWER_FLAGS_HELP: string;
|
|
37
|
+
/**
|
|
38
|
+
* yargs options for `wdio config`, keyed in kebab-case so `--help` shows the
|
|
39
|
+
* flags as they are typed. yargs still sets the camelCase name on `argv`.
|
|
40
|
+
* No defaults: a flag that is not passed leaves the question to the wizard
|
|
41
|
+
* (or to `--yes`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function getAnswerFlagYargsOptions(): Record<string, {
|
|
44
|
+
desc: string;
|
|
45
|
+
type: "boolean" | "string";
|
|
46
|
+
group: string;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Command line usage of a flag, e.g. `--runner <value>` or `--[no-]typescript`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function answerFlagUsage(flag: AnswerFlag): string;
|
|
52
|
+
/**
|
|
53
|
+
* Turn parsed command line options into wizard answers.
|
|
54
|
+
* Options that were not passed are left out, so the wizard still asks them.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseAnswerFlags(argv: Record<string, unknown>): Partial<Questionnair>;
|
|
57
|
+
/**
|
|
58
|
+
* Turn the options `create-wdio` received back into flags for `wdio config`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function answerFlagsToArgs(argv: Record<string, unknown>): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Check the answers given as flags against the finished questionnaire: every
|
|
63
|
+
* flag has to belong to a question the wizard asks for this setup, and its
|
|
64
|
+
* value has to be one the wizard offers there.
|
|
65
|
+
*/
|
|
66
|
+
export declare function assertAnswerFlagsApply(flagAnswers: Partial<Questionnair>, answers: Questionnair): void;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=answerFlags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answerFlags.d.ts","sourceRoot":"","sources":["../src/answerFlags.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,WAAW,GAAG,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driverIO v10)";
|
|
2
|
+
/**
|
|
3
|
+
* The project-rules block from `website/docs/AIAgents.md`, plus a line that
|
|
4
|
+
* points at the installed skill. Kept here so `npm init wdio` can write it
|
|
5
|
+
* without the website package.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AGENT_SECTION = "## End-to-end tests (WebdriverIO v10)\n\n- Docs: https://webdriver.io/llms.txt - fetch the relevant page as Markdown (append `.md`) before using an API you are not sure about. Do not use APIs from WebdriverIO v8 or older.\n- Config: `wdio.conf.ts`. Specs: `test/specs/**/*.e2e.ts`. Page objects: `test/pageobjects/`.\n- Run all tests: `npx wdio run wdio.conf.ts`\n- Run a single spec: `npx wdio run wdio.conf.ts --spec test/specs/login.e2e.ts`\n- Tests are async: always `await` commands, e.g. `await $('button').click()`. Never use the removed sync mode.\n- Prefer user-facing selectors: accessibility name or text (`$('aria/Submit')`, `$('button=Submit')`), then `data-testid`. Avoid XPath and generated CSS classes.\n- Rely on auto-waiting and `expect-webdriverio` matchers (`await expect($('h1')).toHaveText('Welcome')`) instead of `browser.pause()`.\n- To explore the app or verify a selector, use the `wdio-mcp` MCP server.\n- To drive the app from the shell, follow `.agents/skills/wdio-session/SKILL.md` (`npx wdio session`).\n- When a test fails, read the DevTools trace in `test-results/` (see `transcript.md`) before changing code.\n";
|
|
8
|
+
/**
|
|
9
|
+
* The skill ships in this repo at `@wdio/session` and, for the published
|
|
10
|
+
* `create-wdio` package, as `templates/wdio-session/SKILL.md`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readSessionSkill(start?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Write the skill, the AGENTS.md section and `.wdio/session/` in `.gitignore`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeAgentSupport(root: string): void;
|
|
17
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/cli/agent.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,0CAA0C,CAAA;AAE5E;;;;GAIG;AACH,eAAO,MAAM,aAAa,6nCAYzB,CAAA;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAE,KAAK,SAA+C,UAsBrF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,MAAM,QAsB9C"}
|
package/build/cli/config.d.ts
CHANGED
|
@@ -22,19 +22,19 @@ export declare const cmdArgs: {
|
|
|
22
22
|
readonly default: "latest";
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "
|
|
26
|
-
|
|
25
|
+
export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, "yes" | "npmTag" | "yarn"> & import("yargs").InferredOptionTypes<{
|
|
26
|
+
yarn: {
|
|
27
27
|
readonly type: "boolean";
|
|
28
28
|
readonly desc: "Install packages via Yarn package manager.";
|
|
29
29
|
readonly default: boolean;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
yes: {
|
|
32
32
|
readonly alias: "y";
|
|
33
33
|
readonly desc: "will fill in all config defaults without prompting";
|
|
34
34
|
readonly type: "boolean";
|
|
35
35
|
readonly default: false;
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
npmTag: {
|
|
38
38
|
readonly alias: "t";
|
|
39
39
|
readonly desc: "define NPM tag to use for WebdriverIO related packages";
|
|
40
40
|
readonly type: "string";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAIjC,OAAO,EAEH,gBAAgB,EACnB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAIjC,OAAO,EAEH,gBAAgB,EACnB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAUzD,eAAO,MAAM,OAAO,WAAW,CAAA;AAC/B,eAAO,MAAM,IAAI,4EAA4E,CAAA;AAE7F,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;CAkBV,CAAA;AAEV,eAAO,MAAM,OAAO,GAAI,OAAO,IAAI;;;;;;;;;;;;;;;;;;GAUlC,CAAA;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,sBAAsB,EAAE,YAAY,0BAAmB;;;;GAiB1F;AAED,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAG,MAAM,YAAY,CAAA;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA"}
|
package/build/cli/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ParsedAnswers } from '../types.js';
|
|
2
|
-
export declare function runConfigCommand(parsedAnswers: ParsedAnswers, npmTag: string): Promise<void>;
|
|
1
|
+
import type { ParsedAnswers, Questionnair } from '../types.js';
|
|
2
|
+
export declare function runConfigCommand(parsedAnswers: ParsedAnswers, npmTag: string, yes?: boolean): Promise<void>;
|
|
3
3
|
/**
|
|
4
4
|
* Helper utility used in `run` and `install` command to create config if none exist
|
|
5
5
|
* @param {string} command to be executed by user
|
|
@@ -7,7 +7,19 @@ export declare function runConfigCommand(parsedAnswers: ParsedAnswers, npmTag: s
|
|
|
7
7
|
* @param {Function} runConfigCmd runConfig method to be replaceable for unit testing
|
|
8
8
|
*/
|
|
9
9
|
export declare function missingConfigurationPrompt(command: string, configPath: string, runConfigCmd?: Function): Promise<string>;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Resolve where the generated WDIO TypeScript config should live.
|
|
12
|
+
* Never overwrite an existing root `tsconfig.json` — when that would happen
|
|
13
|
+
* (for example a direct-child spec glob like `e2e/*.ts`), fall back to a
|
|
14
|
+
* dedicated `tsconfig.e2e.json` / `tsconfig.wdio.json`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveTsConfigFilePath({ projectRootDir, hasRootTSConfig, specs, runnerShort }: {
|
|
17
|
+
projectRootDir: string;
|
|
18
|
+
hasRootTSConfig: boolean;
|
|
19
|
+
specs?: string;
|
|
20
|
+
runnerShort: string;
|
|
21
|
+
}): string;
|
|
22
|
+
export declare const parseAnswers: (yes: boolean, flagAnswers?: Partial<Questionnair>) => Promise<ParsedAnswers>;
|
|
11
23
|
/**
|
|
12
24
|
* Helper utility used in `run` and `install` command to check whether a config file currently exists
|
|
13
25
|
* @param configPathNoExtension the file path to the WDIO config file without extension
|
package/build/cli/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI9D,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAQ,iBAuC/F;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,GAAE,QAA2B,mBAsB9H;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACpC,cAAc,EACd,eAAe,EACf,KAAK,EACL,WAAW,EACd,EAAE;IACC,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;CACtB,UAwBA;AAED,eAAO,MAAM,YAAY,GAAmB,KAAK,OAAO,EAAE,cAAa,OAAO,CAAC,YAAY,CAAM,KAAG,OAAO,CAAC,aAAa,CA2ExH,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,qBAAqB,EAAC,MAAM,EAAE,UAAU,CAAC,EAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAC,SAAS,CAAC,CAcrH"}
|