codeceptjs 3.5.12 → 3.5.13-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.
package/README.md CHANGED
@@ -313,10 +313,10 @@ Thanks all to those who are and will have contributing to this awesome project!
313
313
  <a href="https://github.com/tsuemura"><img src="https://avatars.githubusercontent.com/u/17092259?v=4" title="tsuemura" width="80" height="80"></a>
314
314
  <a href="https://github.com/EgorBodnar"><img src="https://avatars.githubusercontent.com/u/63167966?v=4" title="EgorBodnar" width="80" height="80"></a>
315
315
  <a href="https://github.com/VikalpP"><img src="https://avatars.githubusercontent.com/u/11846339?v=4" title="VikalpP" width="80" height="80"></a>
316
- <a href="https://github.com/BorisOsipov"><img src="https://avatars.githubusercontent.com/u/6514276?v=4" title="BorisOsipov" width="80" height="80"></a>
317
316
  <a href="https://github.com/elaichenkov"><img src="https://avatars.githubusercontent.com/u/29764053?v=4" title="elaichenkov" width="80" height="80"></a>
318
- <a href="https://github.com/nitschSB"><img src="https://avatars.githubusercontent.com/u/39341455?v=4" title="nitschSB" width="80" height="80"></a>
317
+ <a href="https://github.com/BorisOsipov"><img src="https://avatars.githubusercontent.com/u/6514276?v=4" title="BorisOsipov" width="80" height="80"></a>
319
318
  <a href="https://github.com/hubidu"><img src="https://avatars.githubusercontent.com/u/13134082?v=4" title="hubidu" width="80" height="80"></a>
319
+ <a href="https://github.com/nitschSB"><img src="https://avatars.githubusercontent.com/u/39341455?v=4" title="nitschSB" width="80" height="80"></a>
320
320
  <a href="https://github.com/jploskonka"><img src="https://avatars.githubusercontent.com/u/669483?v=4" title="jploskonka" width="80" height="80"></a>
321
321
  <a href="https://github.com/ngraf"><img src="https://avatars.githubusercontent.com/u/7094389?v=4" title="ngraf" width="80" height="80"></a>
322
322
  <a href="https://github.com/maojunxyz"><img src="https://avatars.githubusercontent.com/u/28778042?v=4" title="maojunxyz" width="80" height="80"></a>
@@ -2,6 +2,7 @@ let webdriverio;
2
2
 
3
3
  const fs = require('fs');
4
4
  const axios = require('axios').default;
5
+ const { v4: uuidv4 } = require('uuid');
5
6
 
6
7
  const Webdriver = require('./WebDriver');
7
8
  const AssertionFailedError = require('../assert/error');
@@ -1088,17 +1089,40 @@ class Appium extends Webdriver {
1088
1089
  * Appium: support Android and iOS
1089
1090
  */
1090
1091
  async performSwipe(from, to) {
1091
- await this.browser.touchPerform([{
1092
- action: 'press',
1093
- options: from,
1094
- }, {
1095
- action: 'wait',
1096
- options: { ms: 1000 },
1097
- }, {
1098
- action: 'moveTo',
1099
- options: to,
1100
- }, {
1101
- action: 'release',
1092
+ await this.browser.performActions([{
1093
+ id: uuidv4(),
1094
+ type: 'pointer',
1095
+ parameters: {
1096
+ pointerType: 'touch',
1097
+ },
1098
+ actions: [
1099
+ {
1100
+ duration: 0,
1101
+ x: from.x,
1102
+ y: from.y,
1103
+ type: 'pointerMove',
1104
+ origin: 'viewport',
1105
+ },
1106
+ {
1107
+ button: 1,
1108
+ type: 'pointerDown',
1109
+ },
1110
+ {
1111
+ duration: 200,
1112
+ type: 'pause',
1113
+ },
1114
+ {
1115
+ duration: 600,
1116
+ x: to.x,
1117
+ y: to.y,
1118
+ type: 'pointerMove',
1119
+ origin: 'viewport',
1120
+ },
1121
+ {
1122
+ button: 1,
1123
+ type: 'pointerUp',
1124
+ },
1125
+ ],
1102
1126
  }]);
1103
1127
  await this.browser.pause(1000);
1104
1128
  }
@@ -1128,7 +1152,7 @@ class Appium extends Webdriver {
1128
1152
  yoffset = 100;
1129
1153
  }
1130
1154
 
1131
- return this.swipe(locator, 0, yoffset, speed);
1155
+ return this.swipe(parseLocator.call(this, locator), 0, yoffset, speed);
1132
1156
  }
1133
1157
 
1134
1158
  /**
@@ -1,12 +1,15 @@
1
- const chai = require('chai');
2
1
  const output = require('../output');
3
2
 
4
- const { expect } = chai;
3
+ let expect;
5
4
 
6
- chai.use(require('chai-string'));
7
- // @ts-ignore
8
- chai.use(require('chai-exclude'));
9
- chai.use(require('chai-match-pattern'));
5
+ import('chai').then(chai => {
6
+ expect = chai.expect;
7
+ chai.use(require('chai-string'));
8
+ // @ts-ignore
9
+ chai.use(require('chai-exclude'));
10
+ chai.use(require('chai-match-pattern'));
11
+ chai.use(require('chai-json-schema'));
12
+ });
10
13
 
11
14
  /**
12
15
  * This helper allows performing assertions based on Chai.
@@ -179,7 +182,7 @@ class ExpectHelper {
179
182
  expectJsonSchema(targetData, jsonSchema, customErrorMsg = '') {
180
183
  // @ts-ignore
181
184
  output.step(`I expect "${JSON.stringify(targetData)}" to match this JSON schema "${JSON.stringify(jsonSchema)}"`);
182
- chai.use(require('chai-json-schema'));
185
+
183
186
  return expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema);
184
187
  }
185
188
 
@@ -1,12 +1,13 @@
1
- const assert = require('assert');
2
- const chai = require('chai');
3
- const joi = require('joi');
4
- const chaiDeepMatch = require('chai-deep-match');
5
1
  const Helper = require('@codeceptjs/helper');
6
2
 
7
- chai.use(chaiDeepMatch);
3
+ let expect;
4
+
5
+ import('chai').then(chai => {
6
+ expect = chai.expect;
7
+ chai.use(require('chai-deep-match'));
8
+ });
8
9
 
9
- const { expect } = chai;
10
+ const joi = require('joi');
10
11
 
11
12
  /**
12
13
  * This helper allows performing assertions on JSON responses paired with following helpers:
@@ -91,7 +92,6 @@ class JSONResponse extends Helper {
91
92
  static _checkRequirements() {
92
93
  try {
93
94
  require('joi');
94
- require('chai');
95
95
  } catch (e) {
96
96
  return ['joi'];
97
97
  }
@@ -194,7 +194,7 @@ class JSONResponse extends Helper {
194
194
  fails++;
195
195
  }
196
196
  }
197
- assert.ok(fails < this.response.data.length, `No elements in array matched ${JSON.stringify(json)}`);
197
+ expect(fails < this.response.data.length, `No elements in array matched ${JSON.stringify(json)}`).to.be.true;
198
198
  } else {
199
199
  expect(this.response.data).to.deep.match(json);
200
200
  }
@@ -0,0 +1,221 @@
1
+ const { mock, settings } = require('pactum');
2
+
3
+ /**
4
+ * ## Configuration
5
+ *
6
+ * This helper should be configured in codecept.conf.(js|ts)
7
+ *
8
+ * @typedef MockServerConfig
9
+ * @type {object}
10
+ * @prop {number} [port=9393] - Mock server port
11
+ * @prop {string} [host="0.0.0.0"] - Mock server host
12
+ * @prop {object} [httpsOpts] - key & cert values are the paths to .key and .crt files
13
+ */
14
+ let config = {
15
+ port: 9393,
16
+ host: '0.0.0.0',
17
+ httpsOpts: {
18
+ key: '',
19
+ cert: '',
20
+ },
21
+ };
22
+
23
+ /**
24
+ * MockServer
25
+ *
26
+ * The MockServer Helper in CodeceptJS empowers you to mock any server or service via HTTP or HTTPS, making it an excellent tool for simulating REST endpoints and other HTTP-based APIs.
27
+ *
28
+ * <!-- configuration -->
29
+ *
30
+ * #### Examples
31
+ *
32
+ * You can seamlessly integrate MockServer with other helpers like REST or Playwright. Here's a configuration example inside the `codecept.conf.js` file:
33
+ *
34
+ * ```javascript
35
+ * {
36
+ * helpers: {
37
+ * REST: {...},
38
+ * MockServer: {
39
+ * // default mock server config
40
+ * port: 9393,
41
+ * host: '0.0.0.0',
42
+ * httpsOpts: {
43
+ * key: '',
44
+ * cert: '',
45
+ * },
46
+ * },
47
+ * }
48
+ * }
49
+ * ```
50
+ *
51
+ * #### Adding Interactions
52
+ *
53
+ * Interactions add behavior to the mock server. Use the `I.addInteractionToMockServer()` method to include interactions. It takes an interaction object as an argument, containing request and response details.
54
+ *
55
+ * ```javascript
56
+ * I.addInteractionToMockServer({
57
+ * request: {
58
+ * method: 'GET',
59
+ * path: '/api/hello'
60
+ * },
61
+ * response: {
62
+ * status: 200,
63
+ * body: {
64
+ * 'say': 'hello to mock server'
65
+ * }
66
+ * }
67
+ * });
68
+ * ```
69
+ *
70
+ * #### Request Matching
71
+ *
72
+ * When a real request is sent to the mock server, it matches the received request with the interactions. If a match is found, it returns the specified response; otherwise, a 404 status code is returned.
73
+ *
74
+ * - Strong match on HTTP Method, Path, Query Params & JSON body.
75
+ * - Loose match on Headers.
76
+ *
77
+ * ##### Strong Match on Query Params
78
+ *
79
+ * You can send different responses based on query parameters:
80
+ *
81
+ * ```javascript
82
+ * I.addInteractionToMockServer({
83
+ * request: {
84
+ * method: 'GET',
85
+ * path: '/api/users',
86
+ * queryParams: {
87
+ * id: 1
88
+ * }
89
+ * },
90
+ * response: {
91
+ * status: 200,
92
+ * body: 'user 1'
93
+ * }
94
+ * });
95
+ *
96
+ * I.addInteractionToMockServer({
97
+ * request: {
98
+ * method: 'GET',
99
+ * path: '/api/users',
100
+ * queryParams: {
101
+ * id: 2
102
+ * }
103
+ * },
104
+ * response: {
105
+ * status: 200,
106
+ * body: 'user 2'
107
+ * }
108
+ * });
109
+ * ```
110
+ *
111
+ * - GET to `/api/users?id=1` will return 'user 1'.
112
+ * - GET to `/api/users?id=2` will return 'user 2'.
113
+ * - For all other requests, it returns a 404 status code.
114
+ *
115
+ * ##### Loose Match on Body
116
+ *
117
+ * When `strict` is set to false, it performs a loose match on query params and response body:
118
+ *
119
+ * ```javascript
120
+ * I.addInteractionToMockServer({
121
+ * strict: false,
122
+ * request: {
123
+ * method: 'POST',
124
+ * path: '/api/users',
125
+ * body: {
126
+ * name: 'john'
127
+ * }
128
+ * },
129
+ * response: {
130
+ * status: 200
131
+ * }
132
+ * });
133
+ * ```
134
+ *
135
+ * - POST to `/api/users` with the body containing `name` as 'john' will return a 200 status code.
136
+ * - POST to `/api/users` without the `name` property in the body will return a 404 status code.
137
+ *
138
+ * Happy testing with MockServer in CodeceptJS! 🚀
139
+ *
140
+ * ## Methods
141
+ */
142
+ class MockServer {
143
+ constructor(passedConfig) {
144
+ settings.setLogLevel('SILENT');
145
+ config = { ...passedConfig };
146
+ if (global.debugMode) {
147
+ settings.setLogLevel('VERBOSE');
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Start the mock server
153
+ * @param {number} [port] start the mock server with given port
154
+ *
155
+ * @returns void
156
+ */
157
+ async startMockServer(port) {
158
+ const _config = { ...config };
159
+ if (port) _config.port = port;
160
+ await mock.setDefaults(_config);
161
+ await mock.start();
162
+ }
163
+
164
+ /**
165
+ * Stop the mock server
166
+ *
167
+ * @returns void
168
+ *
169
+ */
170
+ async stopMockServer() {
171
+ await mock.stop();
172
+ }
173
+
174
+ /**
175
+ * An interaction adds behavior to the mock server
176
+ *
177
+ *
178
+ * ```js
179
+ * I.addInteractionToMockServer({
180
+ * request: {
181
+ * method: 'GET',
182
+ * path: '/api/hello'
183
+ * },
184
+ * response: {
185
+ * status: 200,
186
+ * body: {
187
+ * 'say': 'hello to mock server'
188
+ * }
189
+ * }
190
+ * });
191
+ * ```
192
+ * ```js
193
+ * // with query params
194
+ * I.addInteractionToMockServer({
195
+ * request: {
196
+ * method: 'GET',
197
+ * path: '/api/hello',
198
+ * queryParams: {
199
+ * id: 2
200
+ * }
201
+ * },
202
+ * response: {
203
+ * status: 200,
204
+ * body: {
205
+ * 'say': 'hello to mock server'
206
+ * }
207
+ * }
208
+ * });
209
+ * ```
210
+ *
211
+ * @param {CodeceptJS.MockInteraction|object} interaction add behavior to the mock server
212
+ *
213
+ * @returns void
214
+ *
215
+ */
216
+ async addInteractionToMockServer(interaction) {
217
+ await mock.addInteraction(interaction);
218
+ }
219
+ }
220
+
221
+ module.exports = MockServer;
@@ -4,6 +4,7 @@ const fs = require('fs');
4
4
  const Helper = require('@codeceptjs/helper');
5
5
  const { v4: uuidv4 } = require('uuid');
6
6
  const assert = require('assert');
7
+ const promiseRetry = require('promise-retry');
7
8
  const Locator = require('../locator');
8
9
  const store = require('../store');
9
10
  const recorder = require('../recorder');
@@ -50,6 +51,7 @@ const { createValueEngine, createDisabledEngine } = require('./extras/Playwright
50
51
  const {
51
52
  seeElementError, dontSeeElementError, dontSeeElementInDOMError, seeElementInDOMError,
52
53
  } = require('./errors/ElementAssertion');
54
+ const { log } = require('../output');
53
55
 
54
56
  const pathSeparator = path.sep;
55
57
 
@@ -748,9 +750,7 @@ class Playwright extends Helper {
748
750
  });
749
751
  this.context = await this.page;
750
752
  this.contextLocator = null;
751
- if (this.options.browser === 'chrome') {
752
- await page.bringToFront();
753
- }
753
+ await page.bringToFront();
754
754
  }
755
755
 
756
756
  /**
@@ -1805,7 +1805,7 @@ class Playwright extends Helper {
1805
1805
  let optionToSelect = '';
1806
1806
 
1807
1807
  try {
1808
- optionToSelect = await el.locator('option', { hasText: option }).textContent();
1808
+ optionToSelect = (await el.locator('option', { hasText: option }).textContent()).trim();
1809
1809
  } catch (e) {
1810
1810
  optionToSelect = option;
1811
1811
  }
@@ -2890,6 +2890,38 @@ class Playwright extends Helper {
2890
2890
  }
2891
2891
  }
2892
2892
 
2893
+ /**
2894
+ * {{> waitForCookie }}
2895
+ */
2896
+ async waitForCookie(name, sec) {
2897
+ // by default, we will retry 3 times
2898
+ let retries = 3;
2899
+ const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
2900
+
2901
+ if (sec) {
2902
+ retries = sec;
2903
+ } else {
2904
+ retries = Math.ceil(waitTimeout / 1000) - 1;
2905
+ }
2906
+
2907
+ return promiseRetry(async (retry, number) => {
2908
+ const _grabCookie = async (name) => {
2909
+ const cookies = await this.browserContext.cookies();
2910
+ const cookie = cookies.filter(c => c.name === name);
2911
+ if (cookie.length === 0) throw Error(`Cookie ${name} is not found after ${retries}s`);
2912
+ };
2913
+
2914
+ this.debugSection('Wait for cookie: ', name);
2915
+ if (number > 1) this.debugSection('Retrying... Attempt #', number);
2916
+
2917
+ try {
2918
+ await _grabCookie(name);
2919
+ } catch (e) {
2920
+ retry(e);
2921
+ }
2922
+ }, { retries, maxTimeout: 1000 });
2923
+ }
2924
+
2893
2925
  async _waitForAction() {
2894
2926
  return this.wait(this.options.waitForAction / 1000);
2895
2927
  }
@@ -5,6 +5,7 @@ const path = require('path');
5
5
 
6
6
  const Helper = require('@codeceptjs/helper');
7
7
  const { v4: uuidv4 } = require('uuid');
8
+ const promiseRetry = require('promise-retry');
8
9
  const Locator = require('../locator');
9
10
  const recorder = require('../recorder');
10
11
  const store = require('../store');
@@ -1635,6 +1636,38 @@ class Puppeteer extends Helper {
1635
1636
  if (cookie[0]) return cookie[0];
1636
1637
  }
1637
1638
 
1639
+ /**
1640
+ * {{> waitForCookie }}
1641
+ */
1642
+ async waitForCookie(name, sec) {
1643
+ // by default, we will retry 3 times
1644
+ let retries = 3;
1645
+ const waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;
1646
+
1647
+ if (sec) {
1648
+ retries = sec;
1649
+ } else {
1650
+ retries = Math.ceil(waitTimeout / 1000) - 1;
1651
+ }
1652
+
1653
+ return promiseRetry(async (retry, number) => {
1654
+ const _grabCookie = async (name) => {
1655
+ const cookies = await this.page.cookies();
1656
+ const cookie = cookies.filter(c => c.name === name);
1657
+ if (cookie.length === 0) throw Error(`Cookie ${name} is not found after ${retries}s`);
1658
+ };
1659
+
1660
+ this.debugSection('Wait for cookie: ', name);
1661
+ if (number > 1) this.debugSection('Retrying... Attempt #', number);
1662
+
1663
+ try {
1664
+ await _grabCookie(name);
1665
+ } catch (e) {
1666
+ retry(e);
1667
+ }
1668
+ }, { retries, maxTimeout: 1000 });
1669
+ }
1670
+
1638
1671
  /**
1639
1672
  * {{> clearCookie }}
1640
1673
  */
@@ -6,6 +6,7 @@ const fs = require('fs');
6
6
 
7
7
  const Helper = require('@codeceptjs/helper');
8
8
  const crypto = require('crypto');
9
+ const promiseRetry = require('promise-retry');
9
10
  const stringIncludes = require('../assert/include').includes;
10
11
  const { urlEquals, equals } = require('../assert/equal');
11
12
  const { debug } = require('../output');
@@ -1860,6 +1861,37 @@ class WebDriver extends Helper {
1860
1861
  return cookie[0];
1861
1862
  }
1862
1863
 
1864
+ /**
1865
+ * {{> waitForCookie }}
1866
+ */
1867
+ async waitForCookie(name, sec) {
1868
+ // by default, we will retry 3 times
1869
+ let retries = 3;
1870
+ const waitTimeout = sec || this.options.waitForTimeoutInSeconds;
1871
+
1872
+ if (sec) {
1873
+ retries = sec;
1874
+ } else {
1875
+ retries = waitTimeout - 1;
1876
+ }
1877
+
1878
+ return promiseRetry(async (retry, number) => {
1879
+ const _grabCookie = async (name) => {
1880
+ const cookie = await this.browser.getCookies([name]);
1881
+ if (cookie.length === 0) throw Error(`Cookie ${name} is not found after ${retries}s`);
1882
+ };
1883
+
1884
+ this.debugSection('Wait for cookie: ', name);
1885
+ if (number > 1) this.debugSection('Retrying... Attempt #', number);
1886
+
1887
+ try {
1888
+ await _grabCookie(name);
1889
+ } catch (e) {
1890
+ retry(e);
1891
+ }
1892
+ }, { retries, maxTimeout: 1000 });
1893
+ }
1894
+
1863
1895
  /**
1864
1896
  * Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
1865
1897
  * Don't confuse popups with modal windows, as created by [various
package/lib/locator.js CHANGED
@@ -163,7 +163,7 @@ class Locator {
163
163
  */
164
164
  toXPath(pseudoSelector = '') {
165
165
  const locator = `${this.value}${pseudoSelector}`;
166
- const limitation = [':nth-of-type', ':first-of-type', ':last-of-type', ':nth-last-child', ':nth-last-of-type', ':checked', ':disabled', ':enabled', ':required', ':lang'];
166
+ const limitation = [':nth-of-type', ':first-of-type', ':last-of-type', ':nth-last-child', ':nth-last-of-type', ':checked', ':disabled', ':enabled', ':required', ':lang', ':nth-child'];
167
167
 
168
168
  if (limitation.some(item => locator.includes(item))) {
169
169
  cssToXPath = require('css-to-xpath');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.5.12",
3
+ "version": "3.5.13-beta.1",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -55,6 +55,7 @@
55
55
  "test:unit:webbapi:webDriver:devtools": "mocha test/helper/WebDriver_devtools_test.js --exit",
56
56
  "test:unit:webbapi:testCafe": "mocha test/helper/TestCafe_test.js",
57
57
  "test:unit:expect": "mocha test/helper/Expect_test.js",
58
+ "test:unit:mockServer": "mocha test/helper/MockServer_test.js",
58
59
  "test:plugin": "mocha test/plugin/plugin_test.js",
59
60
  "def": "./runok.js def",
60
61
  "dev:graphql": "node test/data/graphql/index.js",
@@ -71,10 +72,10 @@
71
72
  "@cucumber/gherkin": "26",
72
73
  "@cucumber/messages": "24.0.1",
73
74
  "@xmldom/xmldom": "0.8.10",
74
- "acorn": "8.11.2",
75
+ "acorn": "8.11.3",
75
76
  "arrify": "2.0.1",
76
77
  "axios": "1.6.3",
77
- "chai": "4.3.8",
78
+ "chai": "5.0.3",
78
79
  "chai-deep-match": "1.2.1",
79
80
  "chai-exclude": "2.1.0",
80
81
  "chai-json-schema": "1.5.1",
@@ -86,7 +87,7 @@
86
87
  "cross-spawn": "7.0.3",
87
88
  "css-to-xpath": "0.1.0",
88
89
  "csstoxpath": "1.6.0",
89
- "devtools": "8.27.2",
90
+ "devtools": "8.29.1",
90
91
  "envinfo": "7.11.0",
91
92
  "escape-string-regexp": "4.0.0",
92
93
  "figures": "3.2.0",
@@ -95,7 +96,6 @@
95
96
  "glob": "6.0.1",
96
97
  "html-minifier-terser": "7.2.0",
97
98
  "inquirer": "6.5.2",
98
- "joi": "17.11.0",
99
99
  "js-beautify": "1.14.11",
100
100
  "lodash.clonedeep": "4.5.0",
101
101
  "lodash.merge": "4.6.2",
@@ -104,6 +104,7 @@
104
104
  "ms": "2.1.3",
105
105
  "openai": "3.2.1",
106
106
  "ora-classic": "5.4.2",
107
+ "pactum": "3.6.0",
107
108
  "parse-function": "5.6.4",
108
109
  "parse5": "7.1.2",
109
110
  "promise-retry": "1.1.1",
@@ -121,8 +122,8 @@
121
122
  "@pollyjs/core": "5.1.0",
122
123
  "@types/chai": "4.3.7",
123
124
  "@types/inquirer": "9.0.3",
124
- "@types/node": "20.10.7",
125
- "@wdio/sauce-service": "8.27.0",
125
+ "@types/node": "20.11.16",
126
+ "@wdio/sauce-service": "8.29.1",
126
127
  "@wdio/selenium-standalone-service": "8.3.2",
127
128
  "@wdio/utils": "8.28.8",
128
129
  "@xmldom/xmldom": "0.8.10",
@@ -152,7 +153,7 @@
152
153
  "runok": "0.9.3",
153
154
  "sinon": "17.0.1",
154
155
  "sinon-chai": "3.7.0",
155
- "testcafe": "3.3.0",
156
+ "testcafe": "3.5.0",
156
157
  "ts-morph": "21.0.1",
157
158
  "ts-node": "10.9.2",
158
159
  "tsd-jsdoc": "2.5.0",
@@ -169,4 +170,4 @@
169
170
  "npm": ">=5.6.0"
170
171
  },
171
172
  "es6": true
172
- }
173
+ }
@@ -382,6 +382,22 @@ declare namespace CodeceptJS {
382
382
  [key: string]: any;
383
383
  };
384
384
 
385
+ type MockRequest = {
386
+ method: 'GET'|'PUT'|'POST'|'PATCH'|'DELETE'|string;
387
+ path: string;
388
+ queryParams?: object;
389
+ }
390
+
391
+ type MockResponse = {
392
+ status: number;
393
+ body?: object;
394
+ }
395
+
396
+ type MockInteraction = {
397
+ request: MockRequest;
398
+ response: MockResponse;
399
+ }
400
+
385
401
  interface PageScrollPosition {
386
402
  x: number;
387
403
  y: number;
@@ -4646,6 +4646,16 @@ declare namespace CodeceptJS {
4646
4646
  * @param [sec = 1] - (optional, `1` by default) time in seconds to wait
4647
4647
  */
4648
4648
  waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): Promise<any>;
4649
+ /**
4650
+ * Waits for the specified cookie in the cookies.
4651
+ *
4652
+ * ```js
4653
+ * I.waitForCookie("token");
4654
+ * ```
4655
+ * @param name - expected cookie name.
4656
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
4657
+ */
4658
+ waitForCookie(name: string, sec?: number): Promise<any>;
4649
4659
  /**
4650
4660
  * Grab the data from performance timing using Navigation Timing API.
4651
4661
  * The returned data will contain following things in ms:
@@ -7296,6 +7306,16 @@ declare namespace CodeceptJS {
7296
7306
  * @param [name = null] - cookie name.
7297
7307
  */
7298
7308
  grabCookie(name?: string): Promise<any>;
7309
+ /**
7310
+ * Waits for the specified cookie in the cookies.
7311
+ *
7312
+ * ```js
7313
+ * I.waitForCookie("token");
7314
+ * ```
7315
+ * @param name - expected cookie name.
7316
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
7317
+ */
7318
+ waitForCookie(name: string, sec?: number): Promise<any>;
7299
7319
  /**
7300
7320
  * Clears a cookie by name,
7301
7321
  * if none provided clears all cookies.
@@ -10146,6 +10166,16 @@ declare namespace CodeceptJS {
10146
10166
  * @param [name = null] - cookie name.
10147
10167
  */
10148
10168
  grabCookie(name?: string): Promise<any>;
10169
+ /**
10170
+ * Waits for the specified cookie in the cookies.
10171
+ *
10172
+ * ```js
10173
+ * I.waitForCookie("token");
10174
+ * ```
10175
+ * @param name - expected cookie name.
10176
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
10177
+ */
10178
+ waitForCookie(name: string, sec?: number): Promise<any>;
10149
10179
  /**
10150
10180
  * Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
10151
10181
  * Don't confuse popups with modal windows, as created by [various
@@ -4892,6 +4892,17 @@ declare namespace CodeceptJS {
4892
4892
  * @returns automatically synchronized promise through #recorder
4893
4893
  */
4894
4894
  waitForDetached(locator: CodeceptJS.LocatorOrString, sec?: number): void;
4895
+ /**
4896
+ * Waits for the specified cookie in the cookies.
4897
+ *
4898
+ * ```js
4899
+ * I.waitForCookie("token");
4900
+ * ```
4901
+ * @param name - expected cookie name.
4902
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
4903
+ * @returns automatically synchronized promise through #recorder
4904
+ */
4905
+ waitForCookie(name: string, sec?: number): void;
4895
4906
  /**
4896
4907
  * Grab the data from performance timing using Navigation Timing API.
4897
4908
  * The returned data will contain following things in ms:
@@ -7757,6 +7768,17 @@ declare namespace CodeceptJS {
7757
7768
  * Returns cookie in JSON format. If name not passed returns all cookies for this domain.
7758
7769
  */
7759
7770
  grabCookie(name?: string): any;
7771
+ /**
7772
+ * Waits for the specified cookie in the cookies.
7773
+ *
7774
+ * ```js
7775
+ * I.waitForCookie("token");
7776
+ * ```
7777
+ * @param name - expected cookie name.
7778
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
7779
+ * @returns automatically synchronized promise through #recorder
7780
+ */
7781
+ waitForCookie(name: string, sec?: number): void;
7760
7782
  /**
7761
7783
  * Clears a cookie by name,
7762
7784
  * if none provided clears all cookies.
@@ -10852,6 +10874,17 @@ declare namespace CodeceptJS {
10852
10874
  * @returns attribute value
10853
10875
  */
10854
10876
  grabCookie(name?: string): any;
10877
+ /**
10878
+ * Waits for the specified cookie in the cookies.
10879
+ *
10880
+ * ```js
10881
+ * I.waitForCookie("token");
10882
+ * ```
10883
+ * @param name - expected cookie name.
10884
+ * @param [sec = 3] - (optional, `3` by default) time in seconds to wait
10885
+ * @returns automatically synchronized promise through #recorder
10886
+ */
10887
+ waitForCookie(name: string, sec?: number): void;
10855
10888
  /**
10856
10889
  * Accepts the active JavaScript native popup window, as created by window.alert|window.confirm|window.prompt.
10857
10890
  * Don't confuse popups with modal windows, as created by [various