codeceptjs 3.3.8-beta.1 → 3.4.0-beta.1

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +31 -32
  3. package/docs/advanced.md +48 -24
  4. package/docs/basics.md +115 -40
  5. package/docs/best.md +2 -2
  6. package/docs/build/ApiDataFactory.js +6 -6
  7. package/docs/build/Appium.js +2 -19
  8. package/docs/build/FileSystem.js +2 -2
  9. package/docs/build/GraphQLDataFactory.js +2 -2
  10. package/docs/build/Playwright.js +3 -2
  11. package/docs/build/TestCafe.js +4 -4
  12. package/docs/build/WebDriver.js +29 -164
  13. package/docs/helpers/ApiDataFactory.md +6 -6
  14. package/docs/helpers/FileSystem.md +2 -2
  15. package/docs/helpers/GraphQLDataFactory.md +2 -2
  16. package/docs/helpers/Playwright.md +2 -1
  17. package/docs/index.md +1 -1
  18. package/docs/plugins.md +73 -48
  19. package/docs/reports.md +0 -56
  20. package/docs/typescript.md +2 -8
  21. package/lib/actor.js +2 -1
  22. package/lib/cli.js +3 -3
  23. package/lib/codecept.js +2 -1
  24. package/lib/command/generate.js +3 -1
  25. package/lib/command/gherkin/snippets.js +8 -4
  26. package/lib/command/init.js +0 -8
  27. package/lib/command/run-workers.js +3 -6
  28. package/lib/command/utils.js +0 -10
  29. package/lib/command/workers/runTests.js +2 -2
  30. package/lib/config.js +5 -1
  31. package/lib/helper/ApiDataFactory.js +7 -7
  32. package/lib/helper/Appium.js +2 -19
  33. package/lib/helper/FileSystem.js +3 -3
  34. package/lib/helper/GraphQL.js +1 -1
  35. package/lib/helper/GraphQLDataFactory.js +3 -3
  36. package/lib/helper/JSONResponse.js +1 -1
  37. package/lib/helper/Mochawesome.js +1 -1
  38. package/lib/helper/Nightmare.js +1 -1
  39. package/lib/helper/Playwright.js +4 -3
  40. package/lib/helper/Protractor.js +1 -1
  41. package/lib/helper/Puppeteer.js +1 -1
  42. package/lib/helper/REST.js +1 -1
  43. package/lib/helper/TestCafe.js +5 -5
  44. package/lib/helper/WebDriver.js +30 -165
  45. package/lib/helper.js +0 -2
  46. package/lib/interfaces/bdd.js +1 -1
  47. package/lib/interfaces/featureConfig.js +1 -0
  48. package/lib/interfaces/gherkin.js +38 -25
  49. package/lib/listener/exit.js +2 -2
  50. package/lib/listener/retry.js +67 -0
  51. package/lib/listener/steps.js +1 -1
  52. package/lib/listener/timeout.js +47 -10
  53. package/lib/mochaFactory.js +3 -3
  54. package/lib/plugin/allure.js +14 -323
  55. package/lib/plugin/fakerTransform.js +2 -2
  56. package/lib/recorder.js +1 -1
  57. package/lib/scenario.js +25 -18
  58. package/lib/utils.js +6 -0
  59. package/lib/workers.js +4 -7
  60. package/package.json +13 -17
  61. package/typings/index.d.ts +66 -1
  62. package/typings/promiseBasedTypes.d.ts +12 -12
  63. package/typings/types.d.ts +95 -262
package/docs/plugins.md CHANGED
@@ -11,7 +11,9 @@ title: Plugins
11
11
 
12
12
  Allure reporter
13
13
 
14
- ![][1]
14
+ > ⚠️ This plugin was moved to its [own package][1]
15
+
16
+ ![][2]
15
17
 
16
18
  Enables Allure reporter.
17
19
 
@@ -43,7 +45,7 @@ Launch Allure server and see the report like on a screenshot above:
43
45
  - `outputDir` - a directory where allure reports should be stored. Standard output directory is set by default.
44
46
  - `enableScreenshotDiffPlugin` - a boolean flag for add screenshot diff to report.
45
47
  To attach, tou need to attach three files to the report - "diff.png", "actual.png", "expected.png".
46
- See [Allure Screenshot Plugin][2]
48
+ See [Allure Screenshot Plugin][3]
47
49
 
48
50
  #### Public API
49
51
 
@@ -71,7 +73,20 @@ const allure = codeceptjs.container.plugins('allure');
71
73
  });
72
74
  ```
73
75
 
74
- ![Created Step Image][3]
76
+ ![Created Step Image][4]
77
+
78
+ - `addScreenDiff(name, expectedImg, actualImg, diffImg)` - add a special screen diff block to the current test case
79
+ image must be a string representing the contents of the expected image file encoded in base64
80
+ Example of usage:
81
+
82
+ ```js
83
+ const expectedImg = fs.readFileSync('expectedImg.png', { encoding: 'base64' });
84
+ ...
85
+ allure.addScreenDiff('Screen Diff', expectedImg, actualImg, diffImg);
86
+ ```
87
+
88
+ ![Overlay][5]
89
+ ![Diff][6]
75
90
 
76
91
  - `severity(value)` - adds severity label
77
92
  - `epic(value)` - adds epic label
@@ -449,7 +464,7 @@ Possible config options:
449
464
 
450
465
  ## customLocator
451
466
 
452
- Creates a [custom locator][4] by using special attributes in HTML.
467
+ Creates a [custom locator][7] by using special attributes in HTML.
453
468
 
454
469
  If you have a convention to use `data-test-id` or `data-qa` attributes to mark active elements for e2e tests,
455
470
  you can enable this plugin to simplify matching elements with these attributes:
@@ -599,9 +614,9 @@ This method works with WebDriver, Playwright, Puppeteer, Appium helpers.
599
614
  Function parameter `el` represents a matched element.
600
615
  Depending on a helper API of `el` can be different. Refer to API of corresponding browser testing engine for a complete API list:
601
616
 
602
- - [Playwright ElementHandle][5]
603
- - [Puppeteer][6]
604
- - [webdriverio element][7]
617
+ - [Playwright ElementHandle][8]
618
+ - [Puppeteer][9]
619
+ - [webdriverio element][10]
605
620
 
606
621
  #### Configuration
607
622
 
@@ -615,17 +630,17 @@ const eachElement = codeceptjs.container.plugins('eachElement');
615
630
 
616
631
  ### Parameters
617
632
 
618
- - `purpose` **[string][8]**
633
+ - `purpose` **[string][11]**
619
634
  - `locator` **CodeceptJS.LocatorOrString**
620
- - `fn` **[Function][9]**
635
+ - `fn` **[Function][12]**
621
636
 
622
- Returns **([Promise][10]<any> | [undefined][11])**
637
+ Returns **([Promise][13]<any> | [undefined][14])**
623
638
 
624
639
  ## fakerTransform
625
640
 
626
- Use the [faker.js][12] package to generate fake data inside examples on your gherkin tests
641
+ Use the [faker.js][15] package to generate fake data inside examples on your gherkin tests
627
642
 
628
- ![Faker.js][13]
643
+ ![Faker.js][16]
629
644
 
630
645
  #### Usage
631
646
 
@@ -663,7 +678,7 @@ Scenario Outline: ...
663
678
 
664
679
  ## pauseOnFail
665
680
 
666
- Automatically launches [interactive pause][14] when a test fails.
681
+ Automatically launches [interactive pause][17] when a test fails.
667
682
 
668
683
  Useful for debugging flaky tests on local environment.
669
684
  Add this plugin to config file:
@@ -679,6 +694,10 @@ Enable it manually on each run via `-p` option:
679
694
 
680
695
  npx codeceptjs run -p pauseOnFail
681
696
 
697
+ ## reporter
698
+
699
+ Type: Allure
700
+
682
701
  ## retryFailedStep
683
702
 
684
703
  Retries each failed step in a test.
@@ -846,14 +865,14 @@ Possible config options:
846
865
 
847
866
  ## selenoid
848
867
 
849
- [Selenoid][15] plugin automatically starts browsers and video recording.
868
+ [Selenoid][18] plugin automatically starts browsers and video recording.
850
869
  Works with WebDriver helper.
851
870
 
852
871
  ### Prerequisite
853
872
 
854
873
  This plugin **requires Docker** to be installed.
855
874
 
856
- > If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][16] tool from Selenoid
875
+ > If you have issues starting Selenoid with this plugin consider using the official [Configuration Manager][19] tool from Selenoid
857
876
 
858
877
  ### Usage
859
878
 
@@ -882,7 +901,7 @@ plugins: {
882
901
  }
883
902
  ```
884
903
 
885
- When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][17] and start Selenoid automatically.
904
+ When `autoCreate` is enabled it will pull the [latest Selenoid from DockerHub][20] and start Selenoid automatically.
886
905
  It will also create `browsers.json` file required by Selenoid.
887
906
 
888
907
  In automatic mode the latest version of browser will be used for tests. It is recommended to specify exact version of each browser inside `browsers.json` file.
@@ -894,10 +913,10 @@ In automatic mode the latest version of browser will be used for tests. It is re
894
913
  While this plugin can create containers for you for better control it is recommended to create and launch containers manually.
895
914
  This is especially useful for Continous Integration server as you can configure scaling for Selenoid containers.
896
915
 
897
- > Use [Selenoid Configuration Manager][16] to create and start containers semi-automatically.
916
+ > Use [Selenoid Configuration Manager][19] to create and start containers semi-automatically.
898
917
 
899
918
  1. Create `browsers.json` file in the same directory `codecept.conf.js` is located
900
- [Refer to Selenoid documentation][18] to know more about browsers.json.
919
+ [Refer to Selenoid documentation][21] to know more about browsers.json.
901
920
 
902
921
  _Sample browsers.json_
903
922
 
@@ -922,7 +941,7 @@ _Sample browsers.json_
922
941
 
923
942
  2. Create Selenoid container
924
943
 
925
- Run the following command to create a container. To know more [refer here][19]
944
+ Run the following command to create a container. To know more [refer here][22]
926
945
 
927
946
  ```bash
928
947
  docker create \
@@ -955,7 +974,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
955
974
  | enableVideo | Enable video recording and use `video` folder of output (default: false) |
956
975
  | enableLog | Enable log recording and use `logs` folder of output (default: false) |
957
976
  | deletePassed | Delete video and logs of passed tests (default : true) |
958
- | additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][20] to know more |
977
+ | additionalParams | example: `additionalParams: '--env TEST=test'` [Refer here][23] to know more |
959
978
 
960
979
  ### Parameters
961
980
 
@@ -963,7 +982,7 @@ When `allure` plugin is enabled a video is attached to report automatically.
963
982
 
964
983
  ## stepByStepReport
965
984
 
966
- ![step-by-step-report][21]
985
+ ![step-by-step-report][24]
967
986
 
968
987
  Generates step by step report for a test.
969
988
  After each step in a test a screenshot is created. After test executed screenshots are combined into slideshow.
@@ -1144,7 +1163,7 @@ This plugin allows to run webdriverio services like:
1144
1163
  - browserstack
1145
1164
  - appium
1146
1165
 
1147
- A complete list of all available services can be found on [webdriverio website][22].
1166
+ A complete list of all available services can be found on [webdriverio website][25].
1148
1167
 
1149
1168
  #### Setup
1150
1169
 
@@ -1156,7 +1175,7 @@ See examples below:
1156
1175
 
1157
1176
  #### Selenium Standalone Service
1158
1177
 
1159
- Install `@wdio/selenium-standalone-service` package, as [described here][23].
1178
+ Install `@wdio/selenium-standalone-service` package, as [described here][26].
1160
1179
  It is important to make sure it is compatible with current webdriverio version.
1161
1180
 
1162
1181
  Enable `wdio` plugin in plugins list and add `selenium-standalone` service:
@@ -1175,7 +1194,7 @@ Please note, this service can be used with Protractor helper as well!
1175
1194
 
1176
1195
  #### Sauce Service
1177
1196
 
1178
- Install `@wdio/sauce-service` package, as [described here][24].
1197
+ Install `@wdio/sauce-service` package, as [described here][27].
1179
1198
  It is important to make sure it is compatible with current webdriverio version.
1180
1199
 
1181
1200
  Enable `wdio` plugin in plugins list and add `sauce` service:
@@ -1205,50 +1224,56 @@ In the same manner additional services from webdriverio can be installed, enable
1205
1224
 
1206
1225
  - `config`
1207
1226
 
1208
- [1]: https://user-images.githubusercontent.com/220264/45676511-8e052800-bb3a-11e8-8cbb-db5f73de2add.png
1227
+ [1]: https://github.com/codeceptjs/allure-plugin
1228
+
1229
+ [2]: https://user-images.githubusercontent.com/220264/45676511-8e052800-bb3a-11e8-8cbb-db5f73de2add.png
1230
+
1231
+ [3]: https://github.com/allure-framework/allure2/blob/master/plugins/screen-diff-plugin/README.md
1232
+
1233
+ [4]: https://user-images.githubusercontent.com/63167966/139339384-e6e70a62-3638-406d-a224-f32473071428.png
1209
1234
 
1210
- [2]: https://github.com/allure-framework/allure2/blob/master/plugins/screen-diff-plugin/README.md
1235
+ [5]: https://user-images.githubusercontent.com/63167966/215404458-9a325668-819e-4289-9b42-5807c49ebddb.png
1211
1236
 
1212
- [3]: https://user-images.githubusercontent.com/63167966/139339384-e6e70a62-3638-406d-a224-f32473071428.png
1237
+ [6]: https://user-images.githubusercontent.com/63167966/215404645-73b09da0-9e6d-4352-a123-80c22f7014cd.png
1213
1238
 
1214
- [4]: https://codecept.io/locators#custom-locators
1239
+ [7]: https://codecept.io/locators#custom-locators
1215
1240
 
1216
- [5]: https://playwright.dev/docs/api/class-elementhandle
1241
+ [8]: https://playwright.dev/docs/api/class-elementhandle
1217
1242
 
1218
- [6]: https://pptr.dev/#?product=Puppeteer&show=api-class-elementhandle
1243
+ [9]: https://pptr.dev/#?product=Puppeteer&show=api-class-elementhandle
1219
1244
 
1220
- [7]: https://webdriver.io/docs/api
1245
+ [10]: https://webdriver.io/docs/api
1221
1246
 
1222
- [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
1247
+ [11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
1223
1248
 
1224
- [9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1249
+ [12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
1225
1250
 
1226
- [10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1251
+ [13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
1227
1252
 
1228
- [11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
1253
+ [14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
1229
1254
 
1230
- [12]: https://www.npmjs.com/package/faker
1255
+ [15]: https://www.npmjs.com/package/faker
1231
1256
 
1232
- [13]: https://raw.githubusercontent.com/Marak/faker.js/master/logo.png
1257
+ [16]: https://raw.githubusercontent.com/Marak/faker.js/master/logo.png
1233
1258
 
1234
- [14]: /basics/#pause
1259
+ [17]: /basics/#pause
1235
1260
 
1236
- [15]: https://aerokube.com/selenoid/
1261
+ [18]: https://aerokube.com/selenoid/
1237
1262
 
1238
- [16]: https://aerokube.com/cm/latest/
1263
+ [19]: https://aerokube.com/cm/latest/
1239
1264
 
1240
- [17]: https://hub.docker.com/u/selenoid
1265
+ [20]: https://hub.docker.com/u/selenoid
1241
1266
 
1242
- [18]: https://aerokube.com/selenoid/latest/#_prepare_configuration
1267
+ [21]: https://aerokube.com/selenoid/latest/#_prepare_configuration
1243
1268
 
1244
- [19]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
1269
+ [22]: https://aerokube.com/selenoid/latest/#_option_2_start_selenoid_container
1245
1270
 
1246
- [20]: https://docs.docker.com/engine/reference/commandline/create/
1271
+ [23]: https://docs.docker.com/engine/reference/commandline/create/
1247
1272
 
1248
- [21]: https://codecept.io/img/codeceptjs-slideshow.gif
1273
+ [24]: https://codecept.io/img/codeceptjs-slideshow.gif
1249
1274
 
1250
- [22]: https://webdriver.io
1275
+ [25]: https://webdriver.io
1251
1276
 
1252
- [23]: https://webdriver.io/docs/selenium-standalone-service.html
1277
+ [26]: https://webdriver.io/docs/selenium-standalone-service.html
1253
1278
 
1254
- [24]: https://webdriver.io/docs/sauce-service.html
1279
+ [27]: https://webdriver.io/docs/sauce-service.html
package/docs/reports.md CHANGED
@@ -183,62 +183,6 @@ plugins: {
183
183
  [Testomat.io](https://testomat.io) reporter works in the cloud, so it doesn't require you to install additional software. It can be integrated with your CI service to rerun only failed tests, launch new runs from UI, and send report notifications by email or in Slack, MS Teams, or create issue in Jira.
184
184
 
185
185
 
186
- ## Allure
187
-
188
-
189
- [Allure reporter](https://allure.qatools.ru/#) is a tool to store and display test reports.
190
- It provides nice web UI which contains all important information on test execution.
191
- CodeceptJS has built-in support for Allure reports. Inside reports you will have all steps, substeps and screenshots.
192
-
193
- ![](https://user-images.githubusercontent.com/220264/45676511-8e052800-bb3a-11e8-8cbb-db5f73de2add.png)
194
-
195
- > ▶ Allure is a standalone tool. Please refer to [Allure documentation](https://docs.qameta.io/allure/) to learn more about using Allure reports.
196
-
197
- Allure requires **Java 8** to work. Then Allure can be installed via NPM:
198
-
199
- ```
200
- npm install -g allure-commandline --save-dev
201
- ```
202
-
203
- Add [Allure plugin](/plugins/#allure) in config under `plugins` section.
204
-
205
- ```js
206
- plugins: {
207
- allure: {
208
- }
209
- }
210
- ```
211
-
212
- Run tests with allure plugin enabled:
213
-
214
- ```
215
- npx codeceptjs run --plugins allure
216
- ```
217
-
218
- (optionally) To enable allure plugin permanently include `"enabled": true` into plugin config:
219
-
220
-
221
- ```js
222
- "plugins": {
223
- "allure": {
224
- "enabled": true
225
- }
226
- }
227
- ```
228
-
229
- Launch Allure server and see the report like on a screenshot above:
230
-
231
- ```
232
- allure serve output
233
- ```
234
-
235
- Allure reporter aggregates data from other plugins like [*stepByStepReport*](/plugins/#stepByStepReport) and [*screenshotOnFail*](/plugins/#screenshotOnFail)
236
-
237
- Allure reports can also be generated for `dry-run` command. So you can get the first report with no tests actually being executed. Enable allure plugin in dry-run options, and pass `--debug` option to print all tests on screen.
238
-
239
- ```
240
- npx codeceptjs dry-run --debug -p allure
241
- ```
242
186
 
243
187
  ## ReportPortal
244
188
 
@@ -41,16 +41,10 @@ Then select TypeScript as the first question:
41
41
 
42
42
  Then a config file and new tests will be created in TypeScript format.
43
43
 
44
- If a config file is set in TypeScript format (`codecept.conf.ts`) package `node-ts` will be used to run tests.
44
+ If a config file is set in TypeScript format (`codecept.conf.ts`) package `ts-node` will be used to run tests.
45
45
 
46
46
  ## Promise-Based Typings
47
47
 
48
- If you plan to write tests in TypeScript you will probably want to enable "promise-based typings" as you will be asked in `init` command about it:
49
-
50
- ```js
51
- ? Would you prefer to use promise-based typings and explicitly use `await` for all I.* commands?
52
- ```
53
-
54
48
  By default, CodeceptJS tests are written in synchronous mode. This is a regular CodeceptJS test:
55
49
 
56
50
  ```js
@@ -82,7 +76,7 @@ Otherwise they will still return promises but it won't be relfected in type defi
82
76
  To introduce promise-based typings into a current project edit `codecept.conf.ts`:
83
77
 
84
78
  ```ts
85
- fullPromiseBased: true;
79
+ fullPromiseBased: true;
86
80
  ```
87
81
 
88
82
  and rebuild type definitions with
package/lib/actor.js CHANGED
@@ -16,8 +16,9 @@ class Actor {
16
16
  * add print comment method`
17
17
  * @param {string} msg
18
18
  * @param {string} color
19
- * @return {Promise<any> | undefined}
20
19
  * @inner
20
+ *
21
+ * ⚠️ returns a promise which is synchronized internally by recorder
21
22
  */
22
23
  say(msg, color = 'cyan') {
23
24
  return recorder.add(`say ${msg}`, () => {
package/lib/cli.js CHANGED
@@ -40,7 +40,7 @@ class Cli extends Base {
40
40
 
41
41
  runner.on('fail', (test) => {
42
42
  if (test.ctx.currentTest) {
43
- this.loadedTests.push(test.ctx.currentTest.id);
43
+ this.loadedTests.push(test.ctx.currentTest.uid);
44
44
  }
45
45
  if (showSteps && test.steps) {
46
46
  return output.scenario.failed(test);
@@ -57,7 +57,7 @@ class Cli extends Base {
57
57
  } else {
58
58
  skipTestConfig(test, null);
59
59
  }
60
- this.loadedTests.push(test.id);
60
+ this.loadedTests.push(test.uid);
61
61
  cursor.CR();
62
62
  output.test.skipped(test);
63
63
  });
@@ -111,7 +111,7 @@ class Cli extends Base {
111
111
  let skippedCount = 0;
112
112
  const grep = runner._grep;
113
113
  for (const test of suite.tests) {
114
- if (!test.state && !this.loadedTests.includes(test.id)) {
114
+ if (!test.state && !this.loadedTests.includes(test.uid)) {
115
115
  if (matchTest(grep, test.title)) {
116
116
  if (!test.opts) {
117
117
  test.opts = {};
package/lib/codecept.js CHANGED
@@ -67,8 +67,8 @@ class Codecept {
67
67
  global.output_dir = fsPath.resolve(dir, this.config.output);
68
68
 
69
69
  if (!this.config.noGlobals) {
70
+ global.Helper = global.codecept_helper = require('@codeceptjs/helper');
70
71
  global.actor = global.codecept_actor = require('./actor');
71
- global.Helper = global.codecept_helper = require('./helper');
72
72
  global.pause = require('./pause');
73
73
  global.within = require('./within');
74
74
  global.session = require('./session');
@@ -98,6 +98,7 @@ class Codecept {
98
98
  runHook(require('./listener/artifacts'));
99
99
  runHook(require('./listener/config'));
100
100
  runHook(require('./listener/helpers'));
101
+ runHook(require('./listener/retry'));
101
102
  runHook(require('./listener/timeout'));
102
103
  runHook(require('./listener/exit'));
103
104
 
@@ -128,7 +128,9 @@ module.exports.pageObject = function (genPath, opts) {
128
128
  const name = lcfirst(result.name) + ucfirst(kind);
129
129
  let data = readConfig(configFile);
130
130
  config.include[name] = result.filename;
131
- data = data.replace(/include[\s\S][^\}]*/i, `include: ${JSON.stringify(config.include).slice(0, -1)}`);
131
+ const currentInclude = `${data.match(/include:[\s\S][^\}]*/i)[0]}\n ${name}:${JSON.stringify(config.include[name])}`;
132
+
133
+ data = data.replace(/include:[\s\S][^\}]*/i, `${currentInclude}`);
132
134
 
133
135
  fs.writeFileSync(configFile, beautify(data), 'utf-8');
134
136
 
@@ -1,6 +1,7 @@
1
1
  const escapeStringRegexp = require('escape-string-regexp');
2
2
  const fs = require('fs');
3
- const { Parser } = require('gherkin');
3
+ const Gherkin = require('@cucumber/gherkin');
4
+ const Messages = require('@cucumber/messages');
4
5
  const glob = require('glob');
5
6
  const fsPath = require('path');
6
7
 
@@ -9,7 +10,10 @@ const Codecept = require('../../codecept');
9
10
  const output = require('../../output');
10
11
  const { matchStep } = require('../../interfaces/bdd');
11
12
 
12
- const parser = new Parser();
13
+ const uuidFn = Messages.IdGenerator.uuid();
14
+ const builder = new Gherkin.AstBuilder(uuidFn);
15
+ const matcher = new Gherkin.GherkinClassicTokenMatcher();
16
+ const parser = new Gherkin.Parser(builder, matcher);
13
17
  parser.stopAtFirstError = false;
14
18
 
15
19
  module.exports = function (genPath, options) {
@@ -85,8 +89,8 @@ module.exports = function (genPath, options) {
85
89
  const parseFile = (file) => {
86
90
  const ast = parser.parse(fs.readFileSync(file).toString());
87
91
  for (const child of ast.feature.children) {
88
- if (child.type === 'ScenarioOutline') continue; // skip scenario outline
89
- parseSteps(child.steps).map((step) => {
92
+ if (child.scenario.keyword === 'Scenario Outline') continue; // skip scenario outline
93
+ parseSteps(child.scenario.steps).map((step) => {
90
94
  return Object.assign(step, { file: file.replace(global.codecept_dir, '').slice(1) });
91
95
  }).map((step) => newSteps.set(`${step.type}(${step})`, step));
92
96
  }
@@ -126,13 +126,6 @@ module.exports = function (initPath) {
126
126
  default: './output',
127
127
  message: 'Where should logs, screenshots, and reports to be stored?',
128
128
  },
129
- {
130
- name: 'promise',
131
- type: 'confirm',
132
- default: false,
133
- message: 'Would you prefer to use promise-based typings for all I.* commands? http://bit.ly/3XIMq6n',
134
- when: (answers) => answers.typescript,
135
- },
136
129
  {
137
130
  name: 'translation',
138
131
  type: 'list',
@@ -155,7 +148,6 @@ module.exports = function (initPath) {
155
148
  config.tests = result.tests;
156
149
  if (isTypeScript) {
157
150
  config.tests = `${config.tests.replace(/\.js$/, `.${extension}`)}`;
158
- config.fullPromiseBased = result.promise;
159
151
  }
160
152
 
161
153
  // create a directory tests if it is included in tests path
@@ -1,16 +1,10 @@
1
1
  // For Node version >=10.5.0, have to use experimental flag
2
- const { satisfyNodeVersion } = require('./utils');
3
2
  const { tryOrDefault } = require('../utils');
4
3
  const output = require('../output');
5
4
  const event = require('../event');
6
5
  const Workers = require('../workers');
7
6
 
8
7
  module.exports = async function (workerCount, options) {
9
- satisfyNodeVersion(
10
- '>=11.7.0',
11
- 'Required minimum Node version of 11.7.0 to work with "run-workers"',
12
- );
13
-
14
8
  process.env.profile = options.profile;
15
9
 
16
10
  const { config: testConfig, override = '' } = options;
@@ -46,6 +40,9 @@ module.exports = async function (workerCount, options) {
46
40
  try {
47
41
  await workers.bootstrapAll();
48
42
  await workers.run();
43
+ } catch (err) {
44
+ output.error(err);
45
+ process.exit(1);
49
46
  } finally {
50
47
  await workers.teardownAll();
51
48
  }
@@ -1,6 +1,5 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
- const semver = require('semver');
4
3
  const util = require('util');
5
4
  const mkdirp = require('mkdirp');
6
5
 
@@ -71,15 +70,6 @@ function safeFileWrite(file, contents) {
71
70
 
72
71
  module.exports.safeFileWrite = safeFileWrite;
73
72
 
74
- module.exports.satisfyNodeVersion = (
75
- version,
76
- failureMessage = `Required Node version: ${version}`,
77
- ) => {
78
- if (!semver.satisfies(process.version, version)) {
79
- fail(failureMessage);
80
- }
81
- };
82
-
83
73
  module.exports.captureStream = (stream) => {
84
74
  let oldStream;
85
75
  let buffer = '';
@@ -68,7 +68,7 @@ function filterTests() {
68
68
  mocha.loadFiles();
69
69
 
70
70
  for (const suite of mocha.suite.suites) {
71
- suite.tests = suite.tests.filter(test => tests.indexOf(test.id) >= 0);
71
+ suite.tests = suite.tests.filter(test => tests.indexOf(test.uid) >= 0);
72
72
  }
73
73
  }
74
74
 
@@ -124,7 +124,7 @@ function initializeListeners() {
124
124
  return {
125
125
  opts: test.opts || {},
126
126
  tags: test.tags || [],
127
- id: test.id,
127
+ uid: test.uid,
128
128
  workerIndex,
129
129
  retries: test._retries,
130
130
  title: test.title,
package/lib/config.js CHANGED
@@ -79,7 +79,11 @@ class Config {
79
79
  configFile = path.resolve(configFile || '.');
80
80
 
81
81
  if (!fileExists(configFile)) {
82
- throw new Error(`Config file ${configFile} does not exist. Execute 'codeceptjs init' to create config`);
82
+ configFile = configFile.replace('.js', '.ts');
83
+
84
+ if (!fileExists(configFile)) {
85
+ throw new Error(`Config file ${configFile} does not exist. Execute 'codeceptjs init' to create config`);
86
+ }
83
87
  }
84
88
 
85
89
  // is config file
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
2
 
3
- const Helper = require('../helper');
3
+ const Helper = require('@codeceptjs/helper');
4
4
  const REST = require('./REST');
5
5
 
6
6
  /**
@@ -46,8 +46,8 @@ const REST = require('./REST');
46
46
  * ```js
47
47
  * // tests/factories/posts.js
48
48
  *
49
- * const Factory = require('rosie').Factory;
50
- * const faker = require('@faker-js/faker');
49
+ * const { Factory } = require('rosie');
50
+ * const { faker } = require('@faker-js/faker');
51
51
  *
52
52
  * module.exports = new Factory()
53
53
  * // no need to set id, it will be set by REST API
@@ -262,8 +262,8 @@ class ApiDataFactory extends Helper {
262
262
  * ```
263
263
  *
264
264
  * @param {*} factory factory to use
265
- * @param {*} params predefined parameters
266
- * @param {*} options options for programmatically generate the attributes
265
+ * @param {*} [params] predefined parameters
266
+ * @param {*} [options] options for programmatically generate the attributes
267
267
  * @returns {Promise<*>}
268
268
  */
269
269
  have(factory, params, options) {
@@ -288,8 +288,8 @@ class ApiDataFactory extends Helper {
288
288
  *
289
289
  * @param {*} factory
290
290
  * @param {*} times
291
- * @param {*} params
292
- * @param {*} options
291
+ * @param {*} [params]
292
+ * @param {*} [options]
293
293
  */
294
294
  haveMultiple(factory, times, params, options) {
295
295
  const promises = [];