codeceptjs 3.3.5-beta.3 → 3.3.5-beta.6

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.
@@ -11,25 +11,24 @@ After running `codeceptjs init` it should be saved in test root.
11
11
 
12
12
  | Name | Type | Description |
13
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"] } ``` |
14
+ | `bootstrap?` | () => `Promise`<`void`\> \| `boolean` \| `string` | [Execute code before](https://codecept.io/bootstrap/) tests are run. Can be either JS module file or async function: ```bootstrap: async () => server.launch(), ``` or ```bootstrap: 'bootstrap.js', ``` |
15
+ | `bootstrapAll?` | () => `Promise`<`void`\> \| `boolean` \| `string` | [Execute 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: ```gherkin: { features: "./features/*.feature", steps: ["./step_definitions/steps.js"] } ``` |
17
17
  | `gherkin.features` | `string` \| `string`[] | load feature files by pattern. Multiple patterns can be specified as array |
18
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 } } } ``` |
19
+ | `grep?` | `string` | Pattern to filter tests by name. This option is useful if you plan to use multiple configs for different environments. To execute only tests with @firefox tag use ```grep: '@firefox' ``` |
20
+ | `helpers?` | {} | Enable and configure helpers: ```helpers: { Playwright: { url: 'https://mysite.com', browser: 'firefox' } } ``` |
21
+ | `include?` | `any` | Include page objects to access them via dependency injection ```I: "./custom_steps.js", loginPage: "./pages/Login.js", User: "./pages/User.js", ``` Configured modules can be injected by name in a Scenario: ```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: ```mocha: { "mocha-junit-reporter": { stdout: "./output/console.log", options: { mochaFile: "./output/result.xml", attachments: true //add screenshot for a failed test } } } ``` |
23
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
-
24
+ | `output` | `string` | Where to store failure screenshots, artifacts, etc ```output: './output' ``` |
25
+ | `plugins?` | `any` | Enable CodeceptJS plugins. Example: ```plugins: { autoDelay: { enabled: true } } ``` |
26
+ | `require?` | `string`[] | [Require additional JS modules](https://codecept.io/configuration/#require) Example: ``` require: ["should"] ``` |
27
+ | `teardown?` | () => `Promise`<`void`\> \| `boolean` \| `string` | [Execute code after tests](https://codecept.io/bootstrap/) finished. Can be either JS module file or async function: ```teardown: async () => server.stop(), ``` or ```teardown: 'teardown.js', ``` |
28
+ | `teardownAll?` | () => `Promise`<`void`\> \| `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: ```tests: 'tests/**.test.js' ``` For tests in TypeScript: ```tests: 'tests/**.test.ts' ``` |
30
+ | `timeout?` | `number` | Set default tests timeout in seconds. Tests will be killed on no response after timeout. ```timeout: 20, ``` |
31
+ | `translation?` | `string` | Enable [localized test commands](https://codecept.io/translation/) |
33
32
 
34
33
 
35
34
  ## Require
@@ -30,9 +30,10 @@ const packages = [];
30
30
  let isTypeScript = false;
31
31
  let extension = 'js';
32
32
 
33
- const configHeader = `const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');
34
-
33
+ const requireCodeceptConfigure = "const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');";
34
+ const importCodeceptConfigure = "import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';";
35
35
 
36
+ const configHeader = `
36
37
  // turn on headless mode when running with HEADLESS=true environment variable
37
38
  // export HEADLESS=true && npx codeceptjs run
38
39
  setHeadlessWhen(process.env.HEADLESS);
@@ -174,18 +175,21 @@ module.exports = function (initPath) {
174
175
  print(`Steps file created at ${stepFile}`);
175
176
  }
176
177
 
177
- let configSource = beautify(`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`);
178
-
179
- if (require.resolve('@codeceptjs/configure') && isLocal && !initPath) {
180
- // prepend @codeceptjs/configure only when this module can be required in config
181
- configSource = configHeader + configSource;
182
- }
178
+ let configSource;
179
+ const hasConfigure = isLocal && !initPath;
183
180
 
184
181
  if (isTypeScript) {
185
182
  configSource = beautify(`export const config : CodeceptJS.MainConfig = ${inspect(config, false, 4, false)}`);
183
+
184
+ if (hasConfigure) configSource = importCodeceptConfigure + configHeader + configSource;
185
+
186
186
  fs.writeFileSync(typeScriptconfigFile, configSource, 'utf-8');
187
187
  print(`Config created at ${typeScriptconfigFile}`);
188
188
  } else {
189
+ configSource = beautify(`/** @type {CodeceptJS.MainConfig} */\nexports.config = ${inspect(config, false, 4, false)}`);
190
+
191
+ if (hasConfigure) configSource = requireCodeceptConfigure + configHeader + configSource;
192
+
189
193
  fs.writeFileSync(configFile, configSource, 'utf-8');
190
194
  print(`Config created at ${configFile}`);
191
195
  }
package/lib/config.js CHANGED
@@ -5,7 +5,6 @@ const {
5
5
  isFile,
6
6
  deepMerge,
7
7
  deepClone,
8
- requireWithFallback,
9
8
  } = require('./utils');
10
9
 
11
10
  const defaultConfig = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.3.5-beta.3",
3
+ "version": "3.3.5-beta.6",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -133,6 +133,8 @@
133
133
  "testcafe": "^1.18.3",
134
134
  "ts-morph": "^3.1.3",
135
135
  "tsd-jsdoc": "https://github.com/englercj/tsd-jsdoc.git",
136
+ "typedoc": "^0.23.10",
137
+ "typedoc-plugin-markdown": "^3.13.4",
136
138
  "typescript": "^4.4.3",
137
139
  "wdio-docker-service": "^1.5.0",
138
140
  "webdriverio": "^7.16.14",
@@ -32,12 +32,27 @@ declare namespace CodeceptJS {
32
32
  * ```
33
33
  */
34
34
  tests: string;
35
- /** Where to store failure screenshots, artifacts, etc */
35
+ /**
36
+ * Where to store failure screenshots, artifacts, etc
37
+ *
38
+ * ```js
39
+ * output: './output'
40
+ * ```
41
+ */
36
42
  output: string;
37
- /** Pattern to filter tests by name */
43
+ /**
44
+ * Pattern to filter tests by name.
45
+ * This option is useful if you plan to use multiple configs for different environments.
46
+ *
47
+ * To execute only tests with @firefox tag
48
+ *
49
+ * ```js
50
+ * grep: '@firefox'
51
+ * ```
52
+ */
38
53
  grep?: string;
39
54
  /**
40
- * Enabled and configured helpers
55
+ * Enable and configure helpers:
41
56
  *
42
57
  * ```js
43
58
  * helpers: {
@@ -49,17 +64,90 @@ declare namespace CodeceptJS {
49
64
  * ```
50
65
  */
51
66
  helpers?: {
52
- /** Run web tests controlling browsers via Playwright engine. https://codecept.io/playwright */
67
+ /**
68
+ * Run web tests controlling browsers via Playwright engine.
69
+ *
70
+ * https://codecept.io/helpers/playwright
71
+ *
72
+ * Available commands:
73
+ * ```js
74
+ * I.amOnPage('/');
75
+ * I.click('Open');
76
+ * I.see('Welcome');
77
+ * ```
78
+ */
53
79
  Playwright?: PlaywrightConfig;
54
- /** Run web tests controlling browsers via Puppeteer engine. https://codecept.io/puppeteer */
80
+ /**
81
+ * Run web tests controlling browsers via Puppeteer engine.
82
+ *
83
+ * https://codecept.io/helpers/puppeteer
84
+ *
85
+ * Available commands:
86
+ * ```js
87
+ * I.amOnPage('/');
88
+ * I.click('Open');
89
+ * I.see('Welcome');
90
+ * ```
91
+ */
55
92
  Puppeteer?: PuppeteerConfig;
56
- /** Run web tests controlling browsers via WebDriver engine. https://codecept.io/webdriver */
93
+
94
+ /**
95
+ * Run web tests controlling browsers via WebDriver engine.
96
+ *
97
+ * Available commands:
98
+ * ```js
99
+ * I.amOnPage('/');
100
+ * I.click('Open');
101
+ * I.see('Welcome');
102
+ * ```
103
+ *
104
+ * https://codecept.io/helpers/webdriver
105
+ */
57
106
  WebDriver?: WebDriverConfig;
58
- /** Execute REST API requests for API testing or to assist web testing. https://codecept.io/api/ */
107
+ /**
108
+ * Execute REST API requests for API testing or to assist web testing.
109
+ *
110
+ * https://codecept.io/helpers/REST
111
+ *
112
+ * Available commands:
113
+ * ```js
114
+ * I.sendGetRequest('/');
115
+ * ```
116
+ */
59
117
  REST?: RESTConfig;
118
+
119
+ /**
120
+ * Use JSON assertions for API testing.
121
+ * Can be paired with REST or GraphQL helpers.
122
+ *
123
+ * https://codecept.io/helpers/JSONResponse
124
+ *
125
+ * Available commands:
126
+ * ```js
127
+ * I.seeResponseContainsJson({ user: { email: 'jon@doe.com' } });
128
+ * ```
129
+ */
130
+ JSONResponse?: any;
131
+
60
132
  [key: string]: any;
61
133
  },
62
- /** [Enabled plugins](https://codecept.io/plugins/) */
134
+ /**
135
+ * Enable CodeceptJS plugins.
136
+ *
137
+ * https://codecept.io/plugins/
138
+ *
139
+ * Plugins listen to test events and extend functionality of CodeceptJS.
140
+ *
141
+ * Example:
142
+ *
143
+ * ```js
144
+ * plugins: {
145
+ * autoDelay: {
146
+ * enabled: true
147
+ * }
148
+ }
149
+ * ```
150
+ */
63
151
  plugins?: any;
64
152
  /**
65
153
  * Include page objects to access them via dependency injection
@@ -106,7 +194,8 @@ declare namespace CodeceptJS {
106
194
  */
107
195
  mocha?: any;
108
196
  /**
109
- * Execute JS code before tests are run. https://codecept.io/bootstrap/
197
+ * [Execute code before](https://codecept.io/bootstrap/) tests are run.
198
+ *
110
199
  * Can be either JS module file or async function:
111
200
  *
112
201
  * ```js
@@ -119,7 +208,8 @@ declare namespace CodeceptJS {
119
208
  */
120
209
  bootstrap?: () => Promise<void> | boolean | string;
121
210
  /**
122
- * Execute JS code after tests are run. https://codecept.io/bootstrap/
211
+ * [Execute code after tests](https://codecept.io/bootstrap/) finished.
212
+ *
123
213
  * Can be either JS module file or async function:
124
214
  *
125
215
  * ```js
@@ -132,30 +222,29 @@ declare namespace CodeceptJS {
132
222
  */
133
223
  teardown?: () => Promise<void> | boolean | string;
134
224
  /**
135
- * Execute JS code before launching tests in parallel mode.
136
- * https://codecept.io/bootstrap/#bootstrapall-teardownall
137
- */
225
+ * [Execute code before launching tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall)
226
+ *
227
+ */
138
228
  bootstrapAll?: () => Promise<void> | boolean | string;
139
229
  /**
140
- * Execute JS code after finishing tests in parallel mode.
141
- * https://codecept.io/bootstrap/#bootstrapall-teardownall
230
+ * [Execute JS code after finishing tests in parallel mode](https://codecept.io/bootstrap/#bootstrapall-teardownall)
142
231
  */
143
232
  teardownAll?: () => Promise<void> | boolean | string;
144
- /** Enable localized test commands https://codecept.io/translation/ */
233
+ /** Enable [localized test commands](https://codecept.io/translation/) */
145
234
  translation?: string;
146
235
  /**
147
- * Require additional JS modules. https://codecept.io/configuration/#require
236
+ * [Require additional JS modules](https://codecept.io/configuration/#require)
148
237
  *
149
238
  * Example:
150
239
  * ```
151
- * require: ["ts-node/register", "should"]
240
+ * require: ["should"]
152
241
  * ```
153
242
  */
154
243
  require?: Array<string>;
155
244
 
156
245
  /**
157
- * Enable BDD features. https://codecept.io/bdd/#configuration
158
- *
246
+ * Enable [BDD features](https://codecept.io/bdd/#configuration).
247
+ *
159
248
  * Sample configuration:
160
249
  * ```js
161
250
  * gherkin: {