codeceptjs 4.0.0-beta.3 → 4.0.0-beta.4

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.
@@ -113,7 +113,7 @@ declare namespace CodeceptJS {
113
113
  *
114
114
  * module.exports = new Factory()
115
115
  * // no need to set id, it will be set by REST API
116
- * .attr('author', () => faker.name.findName())
116
+ * .attr('author', () => faker.person.findName())
117
117
  * .attr('title', () => faker.lorem.sentence())
118
118
  * .attr('body', () => faker.lorem.paragraph());
119
119
  * ```
@@ -354,6 +354,17 @@ declare namespace CodeceptJS {
354
354
  * ```
355
355
  */
356
356
  runOnAndroid(caps: any, fn: any): void;
357
+ /**
358
+ * Execute code only in Web mode.
359
+ *
360
+ * ```js
361
+ * I.runInWeb(() => {
362
+ * I.waitForElement('#data');
363
+ * I.seeInCurrentUrl('/data');
364
+ * });
365
+ * ```
366
+ */
367
+ runInWeb(): void;
357
368
  /**
358
369
  * Returns app installation status.
359
370
  *
@@ -651,6 +662,19 @@ declare namespace CodeceptJS {
651
662
  * Shortcut for `makeTouchAction`
652
663
  */
653
664
  tap(locator: any): Promise<void>;
665
+ /**
666
+ * Perform a swipe on the screen or an element.
667
+ *
668
+ * ```js
669
+ * let locator = "#io.selendroid.testapp:id/LinearLayout1";
670
+ * I.swipe(locator, 800, 1200, 1000);
671
+ * ```
672
+ *
673
+ * [See complete reference](http://webdriver.io/api/mobile/swipe.html)
674
+ * @param [speed = 1000] - (optional), 1000 by default
675
+ * @returns Appium: support Android and iOS
676
+ */
677
+ swipe(locator: CodeceptJS.LocatorOrString, xoffset: number, yoffset: number, speed?: number): Promise<void>;
654
678
  /**
655
679
  * Perform a swipe on the screen.
656
680
  *
@@ -1204,14 +1228,6 @@ declare namespace CodeceptJS {
1204
1228
  *
1205
1229
  * ## Methods
1206
1230
  */
1207
- // @ts-ignore
1208
- // @ts-ignore
1209
- // @ts-ignore
1210
- // @ts-ignore
1211
- // @ts-ignore
1212
- // @ts-ignore
1213
- // @ts-ignore
1214
- // @ts-ignore
1215
1231
  class ExpectHelper {
1216
1232
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1217
1233
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
@@ -1323,14 +1339,6 @@ declare namespace CodeceptJS {
1323
1339
  *
1324
1340
  * ## Methods
1325
1341
  */
1326
- // @ts-ignore
1327
- // @ts-ignore
1328
- // @ts-ignore
1329
- // @ts-ignore
1330
- // @ts-ignore
1331
- // @ts-ignore
1332
- // @ts-ignore
1333
- // @ts-ignore
1334
1342
  class ExpectHelper {
1335
1343
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1336
1344
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
@@ -1672,7 +1680,7 @@ declare namespace CodeceptJS {
1672
1680
  * input: { ...buildObj },
1673
1681
  * }))
1674
1682
  * // 'attr'-id can be left out depending on the GraphQl resolvers
1675
- * .attr('name', () => faker.name.findName())
1683
+ * .attr('name', () => faker.person.findName())
1676
1684
  * .attr('email', () => faker.interact.email())
1677
1685
  * ```
1678
1686
  * For more options see [rosie documentation](https://github.com/rosiejs/rosie).
@@ -2005,14 +2013,6 @@ declare namespace CodeceptJS {
2005
2013
  * @property [host = "0.0.0.0"] - Mock server host
2006
2014
  * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
2007
2015
  */
2008
- // @ts-ignore
2009
- // @ts-ignore
2010
- // @ts-ignore
2011
- // @ts-ignore
2012
- // @ts-ignore
2013
- // @ts-ignore
2014
- // @ts-ignore
2015
- // @ts-ignore
2016
2016
  type MockServerConfig = {
2017
2017
  port?: number;
2018
2018
  host?: string;
@@ -2137,14 +2137,6 @@ declare namespace CodeceptJS {
2137
2137
  *
2138
2138
  * ## Methods
2139
2139
  */
2140
- // @ts-ignore
2141
- // @ts-ignore
2142
- // @ts-ignore
2143
- // @ts-ignore
2144
- // @ts-ignore
2145
- // @ts-ignore
2146
- // @ts-ignore
2147
- // @ts-ignore
2148
2140
  class MockServer {
2149
2141
  /**
2150
2142
  * Start the mock server
@@ -3284,14 +3276,6 @@ declare namespace CodeceptJS {
3284
3276
  * @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
3285
3277
  * @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
3286
3278
  */
3287
- // @ts-ignore
3288
- // @ts-ignore
3289
- // @ts-ignore
3290
- // @ts-ignore
3291
- // @ts-ignore
3292
- // @ts-ignore
3293
- // @ts-ignore
3294
- // @ts-ignore
3295
3279
  type PlaywrightConfig = {
3296
3280
  url?: string;
3297
3281
  browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
@@ -6819,14 +6803,6 @@ declare namespace CodeceptJS {
6819
6803
  * @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
6820
6804
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
6821
6805
  */
6822
- // @ts-ignore
6823
- // @ts-ignore
6824
- // @ts-ignore
6825
- // @ts-ignore
6826
- // @ts-ignore
6827
- // @ts-ignore
6828
- // @ts-ignore
6829
- // @ts-ignore
6830
6806
  type PuppeteerConfig = {
6831
6807
  url: string;
6832
6808
  basicAuth?: any;
@@ -8769,14 +8745,6 @@ declare namespace CodeceptJS {
8769
8745
  * @property [onResponse] - an async function which can update response object.
8770
8746
  * @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
8771
8747
  */
8772
- // @ts-ignore
8773
- // @ts-ignore
8774
- // @ts-ignore
8775
- // @ts-ignore
8776
- // @ts-ignore
8777
- // @ts-ignore
8778
- // @ts-ignore
8779
- // @ts-ignore
8780
8748
  type RESTConfig = {
8781
8749
  endpoint?: string;
8782
8750
  prettyPrintJson?: boolean;
@@ -8957,6 +8925,17 @@ declare namespace CodeceptJS {
8957
8925
  * @returns response
8958
8926
  */
8959
8927
  sendDeleteRequest(url: any, headers?: any): Promise<any>;
8928
+ /**
8929
+ * Sends DELETE request to API with payload.
8930
+ *
8931
+ * ```js
8932
+ * I.sendDeleteRequestWithPayload('/api/users/1', { author: 'john' });
8933
+ * ```
8934
+ * @param [payload = {}] - the payload to be sent. By default it is sent as an empty object
8935
+ * @param [headers = {}] - the headers object to be sent. By default, it is sent as an empty object
8936
+ * @returns response
8937
+ */
8938
+ sendDeleteRequestWithPayload(url: any, payload?: any, headers?: any): Promise<any>;
8960
8939
  }
8961
8940
  /**
8962
8941
  * SoftAssertHelper is a utility class for performing soft assertions.
@@ -10213,16 +10192,7 @@ declare namespace CodeceptJS {
10213
10192
  * @property [timeouts] - [WebDriver timeouts](http://webdriver.io/docs/timeouts.html) defined as hash.
10214
10193
  * @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
10215
10194
  * @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
10216
- * @property [devtoolsProtocol = false] - enable devtools protocol. Default: false. More info: https://webdriver.io/docs/automationProtocols/#devtools-protocol.
10217
10195
  */
10218
- // @ts-ignore
10219
- // @ts-ignore
10220
- // @ts-ignore
10221
- // @ts-ignore
10222
- // @ts-ignore
10223
- // @ts-ignore
10224
- // @ts-ignore
10225
- // @ts-ignore
10226
10196
  type WebDriverConfig = {
10227
10197
  url: string;
10228
10198
  browser: string;
@@ -10245,7 +10215,6 @@ declare namespace CodeceptJS {
10245
10215
  timeouts?: any;
10246
10216
  highlightElement?: boolean;
10247
10217
  logLevel?: string;
10248
- devtoolsProtocol?: boolean;
10249
10218
  };
10250
10219
  /**
10251
10220
  * WebDriver helper which wraps [webdriverio](http://webdriver.io/) library to
@@ -10351,7 +10320,6 @@ declare namespace CodeceptJS {
10351
10320
  * WebDriver : {
10352
10321
  * url: "http://localhost",
10353
10322
  * browser: "chrome",
10354
- * devtoolsProtocol: true,
10355
10323
  * desiredCapabilities: {
10356
10324
  * chromeOptions: {
10357
10325
  * args: [ "--headless", "--disable-gpu", "--no-sandbox" ]
@@ -12155,34 +12123,6 @@ declare namespace CodeceptJS {
12155
12123
  * @returns scroll position
12156
12124
  */
12157
12125
  grabPageScrollPosition(): Promise<PageScrollPosition>;
12158
- /**
12159
- * This method is **deprecated**.
12160
- *
12161
- *
12162
- * Set the current geo location
12163
- *
12164
- *
12165
- * ```js
12166
- * I.setGeoLocation(121.21, 11.56);
12167
- * I.setGeoLocation(121.21, 11.56, 10);
12168
- * ```
12169
- * @param latitude - to set.
12170
- * @param longitude - to set
12171
- * @param [altitude] - (optional, null by default) to set
12172
- * @returns automatically synchronized promise through #recorder
12173
- */
12174
- setGeoLocation(latitude: number, longitude: number, altitude?: number): void;
12175
- /**
12176
- * This method is **deprecated**.
12177
- *
12178
- * Return the current geo location
12179
- * Resumes test execution, so **should be used inside async function with `await`** operator.
12180
- *
12181
- * ```js
12182
- * let geoLocation = await I.grabGeoLocation();
12183
- * ```
12184
- */
12185
- grabGeoLocation(): Promise<{ latitude: number; longitude: number; altitude: number; }>;
12186
12126
  /**
12187
12127
  * Grab the width, height, location of given locator.
12188
12128
  * Provide `width` or `height`as second param to get your desired prop.
@@ -12209,123 +12149,15 @@ declare namespace CodeceptJS {
12209
12149
  /**
12210
12150
  * Placeholder for ~ locator only test case write once run on both Appium and WebDriver.
12211
12151
  */
12212
- runOnAndroid(caps: any, fn: any): void;
12152
+ runOnIOS(caps: any, fn: any): void;
12213
12153
  /**
12214
12154
  * Placeholder for ~ locator only test case write once run on both Appium and WebDriver.
12215
12155
  */
12216
- runInWeb(): void;
12217
- /**
12218
- * _Note:_ Only works when devtoolsProtocol is enabled.
12219
- *
12220
- * Resets all recorded network requests.
12221
- *
12222
- * ```js
12223
- * I.flushNetworkTraffics();
12224
- * ```
12225
- */
12226
- flushNetworkTraffics(): void;
12227
- /**
12228
- * _Note:_ Only works when devtoolsProtocol is enabled.
12229
- *
12230
- * Stops recording of network traffic. Recorded traffic is not flashed.
12231
- *
12232
- * ```js
12233
- * I.stopRecordingTraffic();
12234
- * ```
12235
- */
12236
- stopRecordingTraffic(): void;
12237
- /**
12238
- * _Note:_ Only works when devtoolsProtocol is enabled.
12239
- *
12240
- * Starts recording the network traffics.
12241
- * This also resets recorded network requests.
12242
- *
12243
- * ```js
12244
- * I.startRecordingTraffic();
12245
- * ```
12246
- * @returns automatically synchronized promise through #recorder
12247
- */
12248
- startRecordingTraffic(): void;
12249
- /**
12250
- * _Note:_ Only works when devtoolsProtocol is enabled.
12251
- *
12252
- * Grab the recording network traffics
12253
- *
12254
- * ```js
12255
- * const traffics = await I.grabRecordedNetworkTraffics();
12256
- * expect(traffics[0].url).to.equal('https://reqres.in/api/comments/1');
12257
- * expect(traffics[0].response.status).to.equal(200);
12258
- * expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
12259
- * ```
12260
- * @returns recorded network traffics
12261
- */
12262
- grabRecordedNetworkTraffics(): any[];
12263
- /**
12264
- * _Note:_ Only works when devtoolsProtocol is enabled.
12265
- *
12266
- * Verifies that a certain request is part of network traffic.
12267
- *
12268
- * ```js
12269
- * // checking the request url contains certain query strings
12270
- * I.amOnPage('https://openai.com/blog/chatgpt');
12271
- * I.startRecordingTraffic();
12272
- * await I.seeTraffic({
12273
- * name: 'sentry event',
12274
- * url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
12275
- * parameters: {
12276
- * width: '1919',
12277
- * height: '1138',
12278
- * },
12279
- * });
12280
- * ```
12281
- *
12282
- * ```js
12283
- * // checking the request url contains certain post data
12284
- * I.amOnPage('https://openai.com/blog/chatgpt');
12285
- * I.startRecordingTraffic();
12286
- * await I.seeTraffic({
12287
- * name: 'event',
12288
- * url: 'https://cloudflareinsights.com/cdn-cgi/rum',
12289
- * requestPostData: {
12290
- * st: 2,
12291
- * },
12292
- * });
12293
- * ```
12294
- * @param opts - options when checking the traffic network.
12295
- * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
12296
- * @param opts.url - Expected URL of request in network traffic
12297
- * @param [opts.parameters] - Expected parameters of that request in network traffic
12298
- * @param [opts.requestPostData] - Expected that request contains post data in network traffic
12299
- * @param [opts.timeout] - Timeout to wait for request in seconds. Default is 10 seconds.
12300
- * @returns automatically synchronized promise through #recorder
12301
- */
12302
- seeTraffic(opts: {
12303
- name: string;
12304
- url: string;
12305
- parameters?: any;
12306
- requestPostData?: any;
12307
- timeout?: number;
12308
- }): void;
12156
+ runOnAndroid(caps: any, fn: any): void;
12309
12157
  /**
12310
- * _Note:_ Only works when devtoolsProtocol is enabled.
12311
- *
12312
- * Verifies that a certain request is not part of network traffic.
12313
- *
12314
- * Examples:
12315
- *
12316
- * ```js
12317
- * I.dontSeeTraffic({ name: 'Unexpected API Call', url: 'https://api.example.com' });
12318
- * I.dontSeeTraffic({ name: 'Unexpected API Call of "user" endpoint', url: /api.example.com.*user/ });
12319
- * ```
12320
- * @param opts - options when checking the traffic network.
12321
- * @param opts.name - A name of that request. Can be any value. Only relevant to have a more meaningful error message in case of fail.
12322
- * @param opts.url - Expected URL of request in network traffic. Can be a string or a regular expression.
12323
- * @returns automatically synchronized promise through #recorder
12158
+ * Placeholder for ~ locator only test case write once run on both Appium and WebDriver.
12324
12159
  */
12325
- dontSeeTraffic(opts: {
12326
- name: string;
12327
- url: string | RegExp;
12328
- }): void;
12160
+ runInWeb(): void;
12329
12161
  }
12330
12162
  interface ActorStatic {
12331
12163
  /**
@@ -12718,7 +12550,7 @@ declare namespace CodeceptJS {
12718
12550
  inside(locator: CodeceptJS.LocatorOrString): Locator;
12719
12551
  after(locator: CodeceptJS.LocatorOrString): Locator;
12720
12552
  before(locator: CodeceptJS.LocatorOrString): Locator;
12721
- static build(locator: CodeceptJS.LocatorOrString): Locator;
12553
+ static build(locator?: CodeceptJS.LocatorOrString): Locator;
12722
12554
  /**
12723
12555
  * Filters to modify locators
12724
12556
  */
@@ -12773,6 +12605,7 @@ declare namespace CodeceptJS {
12773
12605
  function skipped(test: Mocha.Test): void;
12774
12606
  }
12775
12607
  namespace scenario {
12608
+ function started(test: Mocha.Test): void;
12776
12609
  function passed(test: Mocha.Test): void;
12777
12610
  function failed(test: Mocha.Test): void;
12778
12611
  }
@@ -1,221 +0,0 @@
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