codeceptjs 3.1.3 → 3.2.3

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 (75) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/README.md +2 -3
  3. package/bin/codecept.js +1 -0
  4. package/docs/advanced.md +99 -61
  5. package/docs/basics.md +27 -2
  6. package/docs/bdd.md +2 -2
  7. package/docs/build/Appium.js +62 -0
  8. package/docs/build/FileSystem.js +12 -1
  9. package/docs/build/Playwright.js +37 -33
  10. package/docs/build/Protractor.js +9 -24
  11. package/docs/build/Puppeteer.js +10 -28
  12. package/docs/build/REST.js +1 -0
  13. package/docs/build/WebDriver.js +2 -24
  14. package/docs/changelog.md +75 -1
  15. package/docs/configuration.md +8 -8
  16. package/docs/custom-helpers.md +2 -37
  17. package/docs/data.md +9 -9
  18. package/docs/helpers/Appium.md +240 -198
  19. package/docs/helpers/FileSystem.md +12 -2
  20. package/docs/helpers/Playwright.md +226 -225
  21. package/docs/helpers/Puppeteer.md +1 -17
  22. package/docs/helpers/REST.md +3 -1
  23. package/docs/helpers/WebDriver.md +1 -17
  24. package/docs/installation.md +1 -1
  25. package/docs/mobile-react-native-locators.md +3 -0
  26. package/docs/mobile.md +11 -11
  27. package/docs/nightmare.md +3 -3
  28. package/docs/pageobjects.md +2 -0
  29. package/docs/playwright.md +4 -4
  30. package/docs/plugins.md +138 -9
  31. package/docs/puppeteer.md +5 -5
  32. package/docs/reports.md +3 -3
  33. package/docs/testcafe.md +1 -1
  34. package/docs/translation.md +1 -1
  35. package/docs/visual.md +2 -2
  36. package/docs/vue.md +1 -1
  37. package/docs/webdriver.md +2 -2
  38. package/lib/actor.js +19 -1
  39. package/lib/cli.js +25 -20
  40. package/lib/codecept.js +2 -0
  41. package/lib/command/info.js +1 -1
  42. package/lib/command/workers/runTests.js +25 -7
  43. package/lib/config.js +12 -0
  44. package/lib/container.js +3 -1
  45. package/lib/helper/Appium.js +62 -0
  46. package/lib/helper/FileSystem.js +12 -1
  47. package/lib/helper/Playwright.js +37 -23
  48. package/lib/helper/Protractor.js +2 -14
  49. package/lib/helper/Puppeteer.js +3 -18
  50. package/lib/helper/REST.js +1 -0
  51. package/lib/helper/WebDriver.js +2 -14
  52. package/lib/interfaces/featureConfig.js +3 -0
  53. package/lib/interfaces/scenarioConfig.js +4 -0
  54. package/lib/listener/steps.js +21 -3
  55. package/lib/listener/timeout.js +72 -0
  56. package/lib/locator.js +3 -0
  57. package/lib/plugin/allure.js +6 -1
  58. package/lib/plugin/autoLogin.js +1 -1
  59. package/lib/plugin/retryFailedStep.js +4 -3
  60. package/lib/plugin/retryTo.js +130 -0
  61. package/lib/plugin/screenshotOnFail.js +1 -0
  62. package/lib/plugin/stepByStepReport.js +7 -0
  63. package/lib/plugin/stepTimeout.js +91 -0
  64. package/lib/plugin/tryTo.js +6 -0
  65. package/lib/recorder.js +18 -6
  66. package/lib/step.js +58 -0
  67. package/lib/store.js +2 -0
  68. package/lib/ui.js +2 -2
  69. package/package.json +4 -6
  70. package/typings/index.d.ts +8 -1
  71. package/typings/types.d.ts +149 -164
  72. package/docs/angular.md +0 -325
  73. package/docs/helpers/Protractor.md +0 -1658
  74. package/docs/webapi/waitUntil.mustache +0 -11
  75. package/typings/Protractor.d.ts +0 -16
@@ -1614,7 +1614,7 @@ I.seeTitleEquals('Test title.');
1614
1614
 
1615
1615
  #### Parameters
1616
1616
 
1617
- - `text`
1617
+ - `text` **[string][8]** value to check.
1618
1618
 
1619
1619
  ### selectOption
1620
1620
 
@@ -1998,22 +1998,6 @@ I.waitToHide('#popup');
1998
1998
  - `locator` **([string][8] | [object][6])** element located by CSS|XPath|strict locator.
1999
1999
  - `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
2000
2000
 
2001
- ### waitUntil
2002
-
2003
- Waits for a function to return true (waits for 1sec by default).
2004
-
2005
- ```js
2006
- I.waitUntil(() => window.requests == 0);
2007
- I.waitUntil(() => window.requests == 0, 5);
2008
- ```
2009
-
2010
- #### Parameters
2011
-
2012
- - `fn` **([function][12] | [string][8])** function which is executed in browser context.
2013
- - `sec` **[number][10]** (optional, `1` by default) time in seconds to wait
2014
- - `timeoutMsg` **[string][8]** message to show in case of timeout fail.
2015
- - `interval` **[number][10]?**
2016
-
2017
2001
  ### waitUrlEquals
2018
2002
 
2019
2003
  Waits for the entire URL to match the expected
@@ -168,7 +168,7 @@ I.setRequestTimeout(10000); // In milliseconds
168
168
 
169
169
  #### Parameters
170
170
 
171
- - `newTimeout`
171
+ - `newTimeout` **[number][5]** timeout in milliseconds
172
172
 
173
173
  [1]: https://github.com/axios/axios
174
174
 
@@ -177,3 +177,5 @@ I.setRequestTimeout(10000); // In milliseconds
177
177
  [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
178
178
 
179
179
  [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
180
+
181
+ [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
@@ -599,7 +599,7 @@ I.defineTimeout({ implicit: 10000, pageLoad: 10000, script: 5000 });
599
599
 
600
600
  #### Parameters
601
601
 
602
- - `timeouts` **WebdriverIO.Timeouts** WebDriver timeouts object.
602
+ - `timeouts` **any** WebDriver timeouts object.
603
603
 
604
604
  ### dontSee
605
605
 
@@ -2155,22 +2155,6 @@ I.waitToHide('#popup');
2155
2155
  - `locator` **([string][19] | [object][18])** element located by CSS|XPath|strict locator.
2156
2156
  - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2157
2157
 
2158
- ### waitUntil
2159
-
2160
- Waits for a function to return true (waits for 1sec by default).
2161
-
2162
- ```js
2163
- I.waitUntil(() => window.requests == 0);
2164
- I.waitUntil(() => window.requests == 0, 5);
2165
- ```
2166
-
2167
- #### Parameters
2168
-
2169
- - `fn` **([function][24] | [string][19])** function which is executed in browser context.
2170
- - `sec` **[number][22]** (optional, `1` by default) time in seconds to wait
2171
- - `timeoutMsg` **[string][19]** message to show in case of timeout fail.
2172
- - `interval` **[number][22]?**
2173
-
2174
2158
  ### waitUrlEquals
2175
2159
 
2176
2160
  Waits for the entire URL to match the expected
@@ -57,7 +57,7 @@ For WebDriver installation Selenium Server is required 👇
57
57
 
58
58
  ## WebDriver
59
59
 
60
- WebDriver based helpers like WebDriver, Protractor, Selenium WebDriver will require [Selenium Server](http://codecept.io/helpers/WebDriver/#selenium-installation) installed. They will also require ChromeDriver or GeckoDriver to run corresponding browsers.
60
+ WebDriver based helpers like WebDriver, Protractor, Selenium WebDriver will require [Selenium Server](https://codecept.io/helpers/WebDriver/#selenium-installation) installed. They will also require ChromeDriver or GeckoDriver to run corresponding browsers.
61
61
 
62
62
  We recommend to install them manually or use NPM packages:
63
63
 
@@ -1,6 +1,9 @@
1
1
  ## Automating React Native apps
2
2
 
3
3
  ### Problem
4
+
5
+ > ⚠️ **NOTE**: This problem is not actual starting from `react-native@0.65.x` [CHANGELOG](https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#android-specific-9), [#381fb3](https://github.com/facebook/react-native/commit/381fb395ad9d2d48717a5d082aaedbecdd804554)
6
+
4
7
  Let's say we have a React Native app with component defined like this
5
8
  ```html
6
9
  <Button testID='someButton'>My button</Button>
package/docs/mobile.md CHANGED
@@ -6,7 +6,7 @@ title: Mobile Testing with Appium
6
6
  # Mobile Testing with Appium
7
7
 
8
8
  CodeceptJS allows to test mobile and hybrid apps in a similar manner web applications are tested.
9
- Such tests are executed using [Appium](http://appium.io) on emulated or physical devices. Also, Appium allows to test web application on mobile devices.
9
+ Such tests are executed using [Appium](https://appium.io) on emulated or physical devices. Also, Appium allows to test web application on mobile devices.
10
10
 
11
11
  What makes CodeceptJS better for mobile testing?
12
12
  Take a look. Here is the sample test for a native mobile application written in CodeceptJS:
@@ -14,10 +14,10 @@ Take a look. Here is the sample test for a native mobile application written in
14
14
  ```js
15
15
  I.seeAppIsInstalled("io.super.app");
16
16
  I.click('~startUserRegistrationCD');
17
- I.fillField('~email of the customer', 'Nothing special'));
18
- I.see('davert@codecept.io', '~email of the customer'));
19
- I.clearField('~email of the customer'));
20
- I.dontSee('Nothing special', '~email of the customer'));
17
+ I.fillField('~email of the customer', 'Nothing special');
18
+ I.see('davert@codecept.io', '~email of the customer');
19
+ I.clearField('~email of the customer');
20
+ I.dontSee('Nothing special', '~email of the customer');
21
21
  I.seeElement({
22
22
  android: 'android.widget.Button',
23
23
  ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'
@@ -29,15 +29,15 @@ Doesn't it sound cool?
29
29
 
30
30
  ## Setting Up
31
31
 
32
- Ensure that you have [CodeceptJS installed](http://codecept.io/installation/).
33
- You will also need to install [Appium](http://appium.io/).
32
+ Ensure that you have [CodeceptJS installed](https://codecept.io/installation/).
33
+ You will also need to install [Appium](https://appium.io/).
34
34
  We suggest to use [appium-doctor](https://www.npmjs.com/package/appium-doctor) to check if your system is ready for mobile testing.
35
35
 
36
36
  ```sh
37
37
  npm i -g appium-doctor
38
38
  ```
39
39
 
40
- If everything is OK, continue with installing Appium. If not, consider using cloud based alternatives like [SauceLabs](https://saucelabs.com) or [BrowserStack](http://browserstack.com). Cloud services provide hosted appium with real and emulated mobile devices.
40
+ If everything is OK, continue with installing Appium. If not, consider using cloud based alternatives like [SauceLabs](https://saucelabs.com) or [BrowserStack](https://browserstack.com). Cloud services provide hosted appium with real and emulated mobile devices.
41
41
 
42
42
  To install Appium use npm:
43
43
 
@@ -71,7 +71,7 @@ Initialize CodeceptJS with `init` command:
71
71
  npx codeceptjs init
72
72
  ```
73
73
 
74
- Select [Appium helper](http://codecept.io/helpers/Appium/) when asked.
74
+ Select [Appium helper](https://codecept.io/helpers/Appium/) when asked.
75
75
 
76
76
  ```sh
77
77
  ? What helpers do you want to use?
@@ -166,7 +166,7 @@ There are mobile-only methods like:
166
166
  * `hideDeviceKeyboard`,
167
167
  * `seeAppIsInstalled`, `installApp`, `removeApp`, `seeAppIsNotInstalled` - Android only
168
168
 
169
- and [others](http://codecept.io/helpers/Appium/).
169
+ and [others](https://codecept.io/helpers/Appium/).
170
170
 
171
171
  ## Locating Elements
172
172
 
@@ -211,7 +211,7 @@ I.tap('Click me!');
211
211
  I.click('Click me!');
212
212
  ```
213
213
 
214
- Native iOS/Android locators can be used with `android=` and `ios=` prefixes. [Learn more](http://webdriver.io/guide/usage/selectors.html#Mobile-Selectors).
214
+ Native iOS/Android locators can be used with `android=` and `ios=` prefixes. [Learn more](https://webdriver.io/guide/usage/selectors.html#Mobile-Selectors).
215
215
 
216
216
  But how to get all those locators? We recommend to use [Appium Inspector](https://github.com/appium/appium-desktop).
217
217
 
package/docs/nightmare.md CHANGED
@@ -11,7 +11,7 @@ This hardens setting it up testing environment for CI server and slows down test
11
11
 
12
12
  Is there a sane alternative to Selenium?
13
13
 
14
- Yes, how about [NightmareJS](http://www.nightmarejs.org)?
14
+ Yes, how about [NightmareJS](https://www.nightmarejs.org)?
15
15
 
16
16
  It is modern Electron based testing framework which allows to execute tests in headless mode as well as in window mode for debug purposes.
17
17
  This makes Nightmare very useful, much more handy than PhantomJS. Nightmare is in active development and has nice API for writing acceptance tests.
@@ -105,7 +105,7 @@ codeceptjs init
105
105
  ```
106
106
 
107
107
  You will be asked for a Helper to use, you should select Nightmare and provide url of a website you are testing.
108
- Setup process is explained on [QuickStart page](http://codecept.io/quickstart/).
108
+ Setup process is explained on [QuickStart page](https://codecept.io/quickstart/).
109
109
 
110
110
  (If you already have CodeceptJS project, just install nightmare globally or locally and enable it in config)
111
111
 
@@ -171,7 +171,7 @@ Nightmare helper is missing you can easily create `ExtendedNightmare` helper by
171
171
  codeceptjs gh
172
172
  ```
173
173
 
174
- Learn more about [Helpers](http://codecept.io/helpers/).
174
+ Learn more about [Helpers](https://codecept.io/helpers/).
175
175
 
176
176
  Nightmare instance can be accessed by custom helper:
177
177
 
@@ -191,6 +191,8 @@ module.exports = new AttachFile();
191
191
  module.exports.AttachFile = AttachFile;
192
192
  ```
193
193
 
194
+ > ⚠ While building complex page objects it is important to keep all `async` functions to be called with `await`. While CodeceptJS allows to run commands synchronously if async function has `I.grab*` or any custom function that returns a promise it must be called with `await`. If you see `UnhandledPromiseRejectionWarning` it might be caused by async page object function that was called without `await`.
195
+
194
196
  ## Page Fragments
195
197
 
196
198
  Similarly, CodeceptJS allows you to generate **PageFragments** and any other abstractions
@@ -31,7 +31,7 @@ To start you need CodeceptJS with Playwright packages installed
31
31
  npm install codeceptjs playwright --save
32
32
  ```
33
33
 
34
- Or see [alternative installation options](http://codecept.io/installation/)
34
+ Or see [alternative installation options](https://codecept.io/installation/)
35
35
 
36
36
  > If you already have CodeceptJS project, just install `playwright` package and enable a helper it in config.
37
37
 
@@ -84,7 +84,7 @@ When to consider navigation succeeded, defaults to `load`. Given an array of eve
84
84
  When a test runs faster than application it is recommended to increase `waitForAction` config value.
85
85
  It will wait for a small amount of time (100ms) by default after each user action is taken.
86
86
 
87
- > ▶ More options are listed in [helper reference](http://codecept.io/helpers/Playwright/).
87
+ > ▶ More options are listed in [helper reference](https://codecept.io/helpers/Playwright/).
88
88
 
89
89
  ## Writing Tests
90
90
 
@@ -109,7 +109,7 @@ Tests consist with a scenario of user's action taken on a page. The most widely
109
109
  * `see`, `dontSee` - to check for a text on a page
110
110
  * `seeElement`, `dontSeeElement` - to check for elements on a page
111
111
 
112
- > ℹ All actions are listed in [Playwright helper reference](http://codecept.io/helpers/Playwright/).*
112
+ > ℹ All actions are listed in [Playwright helper reference](https://codecept.io/helpers/Playwright/).*
113
113
 
114
114
  All actions which interact with elements can use **[CSS or XPath locators](https://codecept.io/locators/#css-and-xpath)**. Actions like `click` or `fillField` can locate elements by their name or value on a page:
115
115
 
@@ -198,7 +198,7 @@ I.see('0 items left', '.todo-count');
198
198
 
199
199
  > [▶ Learn more about basic commands](/basics#writing-tests)
200
200
 
201
- CodeceptJS allows you to implement custom actions like `I.createTodo` or use **PageObjects**. Learn how to improve your tests in [PageObjects](http://codecept.io/pageobjects/) guide.
201
+ CodeceptJS allows you to implement custom actions like `I.createTodo` or use **PageObjects**. Learn how to improve your tests in [PageObjects](https://codecept.io/pageobjects/) guide.
202
202
 
203
203
  ## Multi Session Testing
204
204
 
package/docs/plugins.md CHANGED
@@ -127,7 +127,7 @@ If a session expires automatically logs in again.
127
127
  ```js
128
128
  // inside a test file
129
129
  // use login to inject auto-login function
130
- Before(login => {
130
+ Before(({ login }) => {
131
131
  login('user'); // login using user session
132
132
  });
133
133
 
@@ -579,9 +579,9 @@ Run tests with plugin enabled:
579
579
 
580
580
  #### Configuration:
581
581
 
582
- - `retries` - number of retries (by default 5),
582
+ - `retries` - number of retries (by default 3),
583
583
  - `when` - function, when to perform a retry (accepts error as parameter)
584
- - `factor` - The exponential factor to use. Default is 2.
584
+ - `factor` - The exponential factor to use. Default is 1.5.
585
585
  - `minTimeout` - The number of milliseconds before starting the first retry. Default is 1000.
586
586
  - `maxTimeout` - The maximum number of milliseconds between two retries. Default is Infinity.
587
587
  - `randomize` - Randomizes the timeouts by multiplying with a factor between 1 to 2. Default is false.
@@ -626,6 +626,75 @@ Scenario('scenario tite', () => {
626
626
 
627
627
  - `config`
628
628
 
629
+ ## retryTo
630
+
631
+ Adds global `retryTo` which retries steps a few times before failing.
632
+
633
+ Enable this plugin in `codecept.conf.js` (enabled by default for new setups):
634
+
635
+ ```js
636
+ plugins: {
637
+ retryTo: {
638
+ enabled: true
639
+ }
640
+ }
641
+ ```
642
+
643
+ Use it in your tests:
644
+
645
+ ```js
646
+ // retry these steps 5 times before failing
647
+ await retryTo((tryNum) => {
648
+ I.switchTo('#editor frame');
649
+ I.click('Open');
650
+ I.see('Opened')
651
+ }, 5);
652
+ ```
653
+
654
+ Set polling interval as 3rd argument (200ms by default):
655
+
656
+ ```js
657
+ // retry these steps 5 times before failing
658
+ await retryTo((tryNum) => {
659
+ I.switchTo('#editor frame');
660
+ I.click('Open');
661
+ I.see('Opened')
662
+ }, 5, 100);
663
+ ```
664
+
665
+ Default polling interval can be changed in a config:
666
+
667
+ ```js
668
+ plugins: {
669
+ retryTo: {
670
+ enabled: true,
671
+ pollInterval: 500,
672
+ }
673
+ }
674
+ ```
675
+
676
+ Disables retryFailedStep plugin for steps inside a block;
677
+
678
+ Use this plugin if:
679
+
680
+ - you need repeat a set of actions in flaky tests
681
+ - iframe was not rendered and you need to retry switching to it
682
+
683
+ #### Configuration
684
+
685
+ - `pollInterval` - default interval between retries in ms. 200 by default.
686
+ - `registerGlobal` - to register `retryTo` function globally, true by default
687
+
688
+ If `registerGlobal` is false you can use retryTo from the plugin:
689
+
690
+ ```js
691
+ const retryTo = codeceptjs.container.plugins('retryTo');
692
+ ```
693
+
694
+ ### Parameters
695
+
696
+ - `config`
697
+
629
698
  ## screenshotOnFail
630
699
 
631
700
  Creates screenshot on failure. Screenshot is saved into `output` directory.
@@ -802,11 +871,67 @@ Possible config options:
802
871
  - `fullPageScreenshots`: should full page screenshots be used. Default: false.
803
872
  - `output`: a directory where reports should be stored. Default: `output`.
804
873
  - `screenshotsForAllureReport`: If Allure plugin is enabled this plugin attaches each saved screenshot to allure report. Default: false.
874
+ - \`disableScreenshotOnFail : Disables the capturing of screeshots after the failed step. Default: true.
805
875
 
806
876
  ### Parameters
807
877
 
808
878
  - `config` **any**
809
879
 
880
+ ## stepTimeout
881
+
882
+ Set timeout for test steps globally.
883
+
884
+ Add this plugin to config file:
885
+
886
+ ```js
887
+ plugins: {
888
+ stepTimeout: {
889
+ enabled: true
890
+ }
891
+ }
892
+ ```
893
+
894
+ Run tests with plugin enabled:
895
+
896
+ npx codeceptjs run --plugins stepTimeout
897
+
898
+ #### Configuration:
899
+
900
+ - `timeout` - global step timeout, default 150 seconds
901
+ - `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false
902
+ - `noTimeoutSteps` - an array of steps with no timeout. Default:
903
+
904
+ - `amOnPage`
905
+ - `wait*`
906
+
907
+ you could set your own noTimeoutSteps which would replace the default one.
908
+
909
+ - `customTimeoutSteps` - an array of step actions with custom timeout. Use it to override or extend noTimeoutSteps.
910
+ You can use step names or step prefixes ending with `*`. As such, `wait*` will match all steps starting with `wait`.
911
+
912
+ #### Example
913
+
914
+ ```js
915
+ plugins: {
916
+ stepTimeout: {
917
+ enabled: true,
918
+ overrideStepLimits: true,
919
+ noTimeoutSteps: [
920
+ 'scroll*', // ignore all scroll steps
921
+ /Cookie/, // ignore all steps with a Cookie in it (by regexp)
922
+ ],
923
+ customTimeoutSteps: [
924
+ ['myFlakyStep*', 1],
925
+ ['scrollWhichRequiresTimeout', 5],
926
+ ]
927
+ }
928
+ }
929
+ ```
930
+
931
+ ### Parameters
932
+
933
+ - `config`
934
+
810
935
  ## subtitles
811
936
 
812
937
  Automatically captures steps as subtitle, and saves it as an artifact when a video is found for a failed test
@@ -856,18 +981,22 @@ Use this plugin if:
856
981
 
857
982
  #### Multiple Conditional Assertions
858
983
 
984
+ ````js
985
+ Add assert requires first:
859
986
  ```js
987
+ const assert = require('assert');
988
+ ````
989
+
990
+ Then use the assert:
860
991
  const result1 = await tryTo(() => I.see('Hello, user'));
861
992
  const result2 = await tryTo(() => I.seeElement('.welcome'));
862
993
  assert.ok(result1 && result2, 'Assertions were not succesful');
863
- ```
864
994
 
865
- ##### Optional click
995
+ ##### Optional click
866
996
 
867
- ```js
868
- I.amOnPage('/');
869
- tryTo(() => I.click('Agree', '.cookies'));
870
- ```
997
+ ```js
998
+ I.amOnPage('/');
999
+ tryTo(() => I.click('Agree', '.cookies'));
871
1000
 
872
1001
  #### Configuration
873
1002
 
package/docs/puppeteer.md CHANGED
@@ -31,7 +31,7 @@ To start you need CodeceptJS with Puppeteer packages installed
31
31
  npm install codeceptjs puppeteer --save
32
32
  ```
33
33
 
34
- Or see [alternative installation options](http://codecept.io/installation/)
34
+ Or see [alternative installation options](https://codecept.io/installation/)
35
35
 
36
36
  > If you already have CodeceptJS project, just install `puppeteer` package and enable a helper it in config.
37
37
 
@@ -80,7 +80,7 @@ By default it is set to `domcontentloaded` which waits for `DOMContentLoaded` ev
80
80
  When a test runs faster than application it is recommended to increase `waitForAction` config value.
81
81
  It will wait for a small amount of time (100ms) by default after each user action is taken.
82
82
 
83
- > ▶ More options are listed in [helper reference](http://codecept.io/helpers/Puppeteer/).
83
+ > ▶ More options are listed in [helper reference](https://codecept.io/helpers/Puppeteer/).
84
84
 
85
85
  ## Writing Tests
86
86
 
@@ -105,7 +105,7 @@ Tests consist with a scenario of user's action taken on a page. The most widely
105
105
  * `see`, `dontSee` - to check for a text on a page
106
106
  * `seeElement`, `dontSeeElement` - to check for elements on a page
107
107
 
108
- > ℹ All actions are listed in [Puppeteer helper reference](http://codecept.io/helpers/Puppeteer/).*
108
+ > ℹ All actions are listed in [Puppeteer helper reference](https://codecept.io/helpers/Puppeteer/).*
109
109
 
110
110
  All actions which interact with elements **support CSS and XPath locators**. Actions like `click` or `fillField` by locate elements by their name or value on a page:
111
111
 
@@ -195,7 +195,7 @@ I.see('0 items left', '.todo-count');
195
195
 
196
196
  > [▶ Learn more about basic commands](/basics#writing-tests)
197
197
 
198
- CodeceptJS allows you to implement custom actions like `I.createTodo` or use **PageObjects**. Learn how to improve your tests in [PageObjects](http://codecept.io/pageobjects/) guide.
198
+ CodeceptJS allows you to implement custom actions like `I.createTodo` or use **PageObjects**. Learn how to improve your tests in [PageObjects](https://codecept.io/pageobjects/) guide.
199
199
 
200
200
  > [▶ Demo project is available on GitHub](https://github.com/DavertMik/codeceptjs-todomvc-puppeteer)
201
201
 
@@ -297,4 +297,4 @@ async renderPageToPdf() {
297
297
 
298
298
  The same way you can also access `browser` object to implement more actions or handle events.
299
299
 
300
- > [▶ Learn more about Helpers](http://codecept.io/helpers/)
300
+ > [▶ Learn more about Helpers](https://codecept.io/helpers/)
package/docs/reports.md CHANGED
@@ -33,8 +33,8 @@ GitHub --
33
33
  Run with --verbose flag to see NodeJS stacktrace
34
34
 
35
35
  ```
36
- npx codeceptjs run --stepsutput add `--steps` option to `run` command:
37
- ```
36
+
37
+ output steps use `--steps` option:
38
38
  ```
39
39
  npx codeceptjs run --steps
40
40
  ```
@@ -145,7 +145,7 @@ npx codecepjs dry-run --debug
145
145
 
146
146
  > ℹ We recommend using Allure reports on CI. Allure is one of the best open-source reporters designed to collect and show test reports in nicest way.
147
147
 
148
- [Allure reporter](http://allure.qatools.ru/#) is a tool to store and display test reports.
148
+ [Allure reporter](https://allure.qatools.ru/#) is a tool to store and display test reports.
149
149
  It provides nice web UI which contains all important information on test execution.
150
150
  CodeceptJS has built-in support for Allure reports. Inside reports you will have all steps, substeps and screenshots.
151
151
 
package/docs/testcafe.md CHANGED
@@ -54,7 +54,7 @@ A first test should be created with `codeceptjs gt` command
54
54
  npx codeceptjs gt
55
55
  ```
56
56
 
57
- In the next example we will [TodoMVC application](http://todomvc.com/examples/angularjs/#/). So let's create a test which will fill in todo list:
57
+ In the next example we will [TodoMVC application](https://todomvc.com/examples/angularjs/#/). So let's create a test which will fill in todo list:
58
58
 
59
59
  ```js
60
60
  Feature('TodoMVC');
@@ -38,7 +38,7 @@ This way tests can be written in native language while it is still JavaScript:
38
38
 
39
39
  ```js
40
40
  Сценарий('пробую написать реферат', (Я) => {
41
- Я.на_странице('http://yandex.ru/referats');
41
+ Я.на_странице('https://yandex.ru/referats');
42
42
  Я.вижу("Написать реферат по");
43
43
  Я.выбираю_опцию('Психологии');
44
44
  Я.кликаю("Написать реферат");
package/docs/visual.md CHANGED
@@ -58,7 +58,7 @@ Base Image is compared with the screenshot image and test results are derived ba
58
58
 
59
59
  ### Example
60
60
 
61
- Lets consider visual testing for [CodeceptJS Home](http://codecept.io)
61
+ Lets consider visual testing for [CodeceptJS Home](https://codecept.io)
62
62
 
63
63
  ```js
64
64
  Feature('To test screen comparison with resemble Js Example test');
@@ -183,7 +183,7 @@ The first time you run this test a new baseline will be created, and subsequent
183
183
 
184
184
  ### Example
185
185
 
186
- Lets consider visual testing for [CodeceptJS Home](http://codecept.io).
186
+ Lets consider visual testing for [CodeceptJS Home](https://codecept.io).
187
187
  You can also find example repo here: https://github.com/PeterNgTr/codeceptjs-applitoolshelper
188
188
 
189
189
  ```js
package/docs/vue.md CHANGED
@@ -111,7 +111,7 @@ If you agreed to create a demo component, you will also see `TestMe` component i
111
111
  * [Learn CodeceptJS basics](/basics)
112
112
  * [Learn how to write CodeceptJS tests with Puppeteer](/puppeteer)
113
113
  * [See full reference for CodeceptJS Puppeteer Helper](/helpers/Puppeteer)
114
- * Ask your questions in [Slack](http://bit.ly/chat-codeceptjs) & [Forum](https://codecept.discourse.group/)
114
+ * Ask your questions in [Slack](https://bit.ly/chat-codeceptjs) & [Forum](https://codecept.discourse.group/)
115
115
 
116
116
  ## Enjoy testing!
117
117
 
package/docs/webdriver.md CHANGED
@@ -250,7 +250,7 @@ An interactive shell output may look like this:
250
250
  ```
251
251
  After typing in successful commands you can copy them into a test.
252
252
 
253
- Here is a test checking basic [todo application](http://todomvc.com/).
253
+ Here is a test checking basic [todo application](https://todomvc.com/).
254
254
 
255
255
  ```js
256
256
  Feature('TodoMVC');
@@ -295,7 +295,7 @@ exports.config = {
295
295
 
296
296
  ## SmartWait
297
297
 
298
- It is possible to wait for elements pragmatically. If a test uses element which is not on a page yet, CodeceptJS will wait for few extra seconds before failing. This feature is based on [Implicit Wait](http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#implicit-waits) of Selenium. CodeceptJS enables implicit wait only when searching for a specific element and disables in all other cases. Thus, the performance of a test is not affected.
298
+ It is possible to wait for elements pragmatically. If a test uses element which is not on a page yet, CodeceptJS will wait for few extra seconds before failing. This feature is based on [Implicit Wait](https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#implicit-waits) of Selenium. CodeceptJS enables implicit wait only when searching for a specific element and disables in all other cases. Thus, the performance of a test is not affected.
299
299
 
300
300
  SmartWait can be enabled by setting wait option in WebDriver config.
301
301
  Add `smartWait: 5000` to wait for additional 5s.
package/lib/actor.js CHANGED
@@ -26,6 +26,24 @@ class Actor {
26
26
  });
27
27
  }
28
28
 
29
+ /**
30
+ * set the maximum execution time for the next step
31
+ * @function
32
+ * @param {number} timeout - step timeout in seconds
33
+ * @return {this}
34
+ * @inner
35
+ */
36
+ limitTime(timeout) {
37
+ if (!store.timeouts) return this;
38
+
39
+ event.dispatcher.prependOnceListener(event.step.before, (step) => {
40
+ output.log(`Timeout to ${step}: ${timeout}s`);
41
+ step.setTimeout(timeout * 1000, Step.TIMEOUT_ORDER.codeLimitTime);
42
+ });
43
+
44
+ return this;
45
+ }
46
+
29
47
  /**
30
48
  * @function
31
49
  * @param {*} [opts]
@@ -114,7 +132,7 @@ function recordStep(step, args) {
114
132
  step.startTime = Date.now();
115
133
  }
116
134
  return val = step.run(...args);
117
- });
135
+ }, false, undefined, step.getTimeout());
118
136
 
119
137
  event.emit(event.step.after, step);
120
138
 
package/lib/cli.js CHANGED
@@ -7,6 +7,7 @@ const { MetaStep } = require('./step');
7
7
 
8
8
  const cursor = Base.cursor;
9
9
  let currentMetaStep = [];
10
+ let codeceptjsEventDispatchersRegistered = false;
10
11
 
11
12
  class Cli extends Base {
12
13
  constructor(runner, opts) {
@@ -77,29 +78,33 @@ class Cli extends Base {
77
78
  }
78
79
  });
79
80
 
80
- event.dispatcher.on(event.step.started, (step) => {
81
- let processingStep = step;
82
- const metaSteps = [];
83
- while (processingStep.metaStep) {
84
- metaSteps.unshift(processingStep.metaStep);
85
- processingStep = processingStep.metaStep;
86
- }
87
- const shift = metaSteps.length;
81
+ if (!codeceptjsEventDispatchersRegistered) {
82
+ codeceptjsEventDispatchersRegistered = true;
88
83
 
89
- for (let i = 0; i < Math.max(currentMetaStep.length, metaSteps.length); i++) {
90
- if (currentMetaStep[i] !== metaSteps[i]) {
91
- output.stepShift = 3 + 2 * i;
92
- if (metaSteps[i]) output.step(metaSteps[i]);
84
+ event.dispatcher.on(event.step.started, (step) => {
85
+ let processingStep = step;
86
+ const metaSteps = [];
87
+ while (processingStep.metaStep) {
88
+ metaSteps.unshift(processingStep.metaStep);
89
+ processingStep = processingStep.metaStep;
93
90
  }
94
- }
95
- currentMetaStep = metaSteps;
96
- output.stepShift = 3 + 2 * shift;
97
- output.step(step);
98
- });
91
+ const shift = metaSteps.length;
99
92
 
100
- event.dispatcher.on(event.step.finished, () => {
101
- output.stepShift = 0;
102
- });
93
+ for (let i = 0; i < Math.max(currentMetaStep.length, metaSteps.length); i++) {
94
+ if (currentMetaStep[i] !== metaSteps[i]) {
95
+ output.stepShift = 3 + 2 * i;
96
+ if (metaSteps[i]) output.step(metaSteps[i]);
97
+ }
98
+ }
99
+ currentMetaStep = metaSteps;
100
+ output.stepShift = 3 + 2 * shift;
101
+ output.step(step);
102
+ });
103
+
104
+ event.dispatcher.on(event.step.finished, () => {
105
+ output.stepShift = 0;
106
+ });
107
+ }
103
108
  }
104
109
 
105
110
  runner.on('suite end', suite => {