codeceptjs 3.2.2 → 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.
@@ -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
 
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
 
@@ -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
 
@@ -981,18 +981,22 @@ Use this plugin if:
981
981
 
982
982
  #### Multiple Conditional Assertions
983
983
 
984
+ ````js
985
+ Add assert requires first:
984
986
  ```js
987
+ const assert = require('assert');
988
+ ````
989
+
990
+ Then use the assert:
985
991
  const result1 = await tryTo(() => I.see('Hello, user'));
986
992
  const result2 = await tryTo(() => I.seeElement('.welcome'));
987
993
  assert.ok(result1 && result2, 'Assertions were not succesful');
988
- ```
989
994
 
990
- ##### Optional click
995
+ ##### Optional click
991
996
 
992
- ```js
993
- I.amOnPage('/');
994
- tryTo(() => I.click('Agree', '.cookies'));
995
- ```
997
+ ```js
998
+ I.amOnPage('/');
999
+ tryTo(() => I.click('Agree', '.cookies'));
996
1000
 
997
1001
  #### Configuration
998
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
@@ -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/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 => {
@@ -73,6 +73,27 @@ function filterTests() {
73
73
  }
74
74
 
75
75
  function initializeListeners() {
76
+ function simplifyError(error) {
77
+ if (error) {
78
+ const {
79
+ stack,
80
+ uncaught,
81
+ message,
82
+ actual,
83
+ expected,
84
+ } = error;
85
+
86
+ return {
87
+ stack,
88
+ uncaught,
89
+ message,
90
+ actual,
91
+ expected,
92
+ };
93
+ }
94
+
95
+ return null;
96
+ }
76
97
  function simplifyTest(test, err = null) {
77
98
  test = { ...test };
78
99
 
@@ -82,13 +103,10 @@ function initializeListeners() {
82
103
  }
83
104
 
84
105
  if (test.err) {
85
- err = {
86
- stack: test.err.stack,
87
- uncaught: test.err.uncaught,
88
- message: test.err.message,
89
- actual: test.err.actual,
90
- expected: test.err.expected,
91
- };
106
+ err = simplifyError(test.err);
107
+ test.status = 'failed';
108
+ } else if (err) {
109
+ err = simplifyError(err);
92
110
  test.status = 'failed';
93
111
  }
94
112
  const parent = {};