Skip to content

Commit 9d2ead7

Browse files
authored
Added typescript typings for CodeceptJS config (#3395)
* added typescript typings for CodeceptJS config * fixed running TS * fixed typings
1 parent 8b8b95d commit 9d2ead7

File tree

17 files changed

+1127
-1621
lines changed

17 files changed

+1127
-1621
lines changed

docs/configuration.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,27 @@ CodeceptJS configuration is set in `codecept.conf.js` file.
99

1010
After running `codeceptjs init` it should be saved in test root.
1111

12-
Here is an overview of available options with their defaults:
13-
14-
* **tests**: `"./*_test.js"` - pattern to locate tests. Allows to enter [glob pattern](https://github.com/isaacs/node-glob), Can either be a pattern to locate tests or an array of patterns to locate tests / test file names.
15-
* **grep**: - pattern to filter tests by name
16-
* **include**: `{}` - actors and page objects to be registered in DI container and included in tests. Accepts objects and module `require` paths
17-
* **timeout**: `10000` - default tests timeout
18-
* **output**: `"./output"` - where to store failure screenshots, etc
19-
* **helpers**: `{}` - list of enabled helpers
20-
* **mocha**: `{}` - mocha options, [reporters](https://codecept.io/reports/) can be configured here
21-
* **multiple**: `{}` - multiple options, see [Multiple Execution](https://codecept.io/parallel#multiple-browsers-execution)
22-
* **bootstrap**: `"./bootstrap.js"` - an option to run code _before_ tests are run. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown)).
23-
* **bootstrapAll**: `"./bootstrap.js"` - an option to run code _before_ all test suites are run when using the run-multiple mode. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown)).
24-
* **teardown**: - an option to run code _after_ all test suites are run when using the run-multiple mode. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown).
25-
* **teardownAll**: - an option to run code _after_ tests are run. See [Hooks](https://codecept.io/hooks/#bootstrap-teardown).
26-
* **noGlobals**: `false` - disable registering global variables like `Actor`, `Helper`, `pause`, `within`, `DataTable`
27-
* **hooks**: - include custom listeners to plug into execution workflow. See [Custom Hooks](https://codecept.io/hooks/#custom-hooks)
28-
* **translation**: - [locale](https://codecept.io/translation/) to be used to print s teps output, as well as used in source code.
29-
* **require**: `[]` - array of module names to be required before codecept starts. See [Require](#require)
12+
| Name | Type | Description |
13+
| :------ | :------ | :------ |
14+
| `bootstrap` | `Function` \| `boolean` \| `string` | Execute JS code before tests are run. https://codecept.io/bootstrap/ Can be either JS module file or async function: ```js bootstrap: async () => server.launch(), ``` or ```js bootstrap: 'bootstrap.js', ``` |
15+
| `bootstrapAll` | `Function` \| `boolean` \| `string` | Execute JS code before launching tests in parallel mode. https://codecept.io/bootstrap/#bootstrapall-teardownall |
16+
| `gherkin?` | { `features`: `string` \| `string`[] ; `steps`: `string`[] } | Enable BDD features. https://codecept.io/bdd/#configuration Sample configuration: ```js gherkin: { features: "./features/*.feature", steps: ["./step_definitions/steps.js"] } ``` |
17+
| `gherkin.features` | `string` \| `string`[] | load feature files by pattern. Multiple patterns can be specified as array |
18+
| `gherkin.steps` | `string`[] | load step definitions from JS files |
19+
| `grep` | `string` | Pattern to filter tests by name |
20+
| `helpers?` | { `[key: string]`: `any`; } | Enabled and configured helpers ```js helpers: { Playwright: { url: 'https://mysite.com', browser: 'firefox' } } ``` |
21+
| `include?` | `any` | Include page objects to access them via dependency injection ```js I: "./custom_steps.js", loginPage: "./pages/Login.js", User: "./pages/User.js", ``` Configured modules can be injected by name in a Scenario: ```js Scenario('test', { I, loginPage, User }) ``` |
22+
| `mocha?` | `any` | [Mocha test runner options](https://mochajs.org/#configuring-mocha-nodejs), additional [reporters](https://codecept.io/reports/#xml) can be configured here. Example: ```js mocha: { "mocha-junit-reporter": { stdout: "./output/console.log", options: { mochaFile: "./output/result.xml", attachments: true //add screenshot for a failed test } } } ``` |
23+
| `noGlobals?` | `boolean` | Disable registering global functions (Before, Scenario, etc). Not recommended |
24+
| `output` | `string` | Where to store failure screenshots, artifacts, etc |
25+
| `plugins?` | `any` | [Enabled plugins](https://codecept.io/plugins/) |
26+
| `require?` | `string`[] | Require additional JS modules. https://codecept.io/configuration/#require Example: ``` require: ["ts-node/register", "should"] ``` |
27+
| `teardown` | `Function` \| `boolean` \| `string` | Execute JS code after tests are run. https://codecept.io/bootstrap/ Can be either JS module file or async function: ```js teardown: async () => server.stop(), ``` or ```js teardown: 'teardown.js', ``` |
28+
| `teardownAll` | `Function` \| `boolean` \| `string` | Execute JS code after finishing tests in parallel mode. https://codecept.io/bootstrap/#bootstrapall-teardownall |
29+
| `tests` | `string` | Pattern to locate CodeceptJS tests. Allows to enter glob pattern or an Array<string> of patterns to match tests / test file names. For tests in JavaScript: ```js tests: 'tests/**.test.js' ``` For tests in TypeScript: ```js tests: 'tests/**.test.ts' ``` |
30+
| `timeout?` | `number` | Set default tests timeout in seconds. Tests will be killed on no response after timeout. ```js timeout: 20, ``` |
31+
| `translation?` | `string` | Enable localized test commands https://codecept.io/translation/ |
32+
3033

3134

3235
## Require

0 commit comments

Comments
 (0)