codeceptjs 3.7.3 → 3.7.5-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 +45 -0
- package/bin/codecept.js +3 -0
- package/bin/test-server.js +53 -0
- package/lib/codecept.js +46 -0
- package/lib/command/init.js +5 -0
- package/lib/command/run-workers.js +16 -1
- package/lib/command/workers/runTests.js +220 -14
- package/lib/container.js +16 -3
- package/lib/element/WebElement.js +327 -0
- package/lib/helper/JSONResponse.js +23 -4
- package/lib/helper/Mochawesome.js +30 -9
- package/lib/helper/Playwright.js +74 -38
- package/lib/helper/Puppeteer.js +107 -28
- package/lib/helper/WebDriver.js +18 -4
- package/lib/listener/retryEnhancer.js +85 -0
- package/lib/listener/steps.js +12 -0
- package/lib/mocha/asyncWrapper.js +13 -3
- package/lib/mocha/cli.js +1 -1
- package/lib/mocha/gherkin.js +1 -1
- package/lib/mocha/test.js +18 -1
- package/lib/mocha/ui.js +13 -0
- package/lib/output.js +8 -10
- package/lib/pause.js +6 -1
- package/lib/plugin/commentStep.js +1 -1
- package/lib/plugin/htmlReporter.js +2955 -0
- package/lib/plugin/screenshotOnFail.js +1 -9
- package/lib/recorder.js +9 -0
- package/lib/test-server.js +323 -0
- package/lib/utils/mask_data.js +53 -0
- package/lib/utils.js +34 -2
- package/lib/workerStorage.js +2 -1
- package/lib/workers.js +135 -9
- package/package.json +41 -37
- package/typings/index.d.ts +17 -4
- package/typings/promiseBasedTypes.d.ts +53 -688
- package/typings/types.d.ts +125 -691
package/typings/types.d.ts
CHANGED
|
@@ -1203,228 +1203,6 @@ declare namespace CodeceptJS {
|
|
|
1203
1203
|
*/
|
|
1204
1204
|
waitForText(text: string, sec?: number, context?: CodeceptJS.LocatorOrString): void;
|
|
1205
1205
|
}
|
|
1206
|
-
/**
|
|
1207
|
-
* This helper allows performing assertions based on Chai.
|
|
1208
|
-
*
|
|
1209
|
-
* ### Examples
|
|
1210
|
-
*
|
|
1211
|
-
* Zero-configuration when paired with other helpers like REST, Playwright:
|
|
1212
|
-
*
|
|
1213
|
-
* ```js
|
|
1214
|
-
* // inside codecept.conf.js
|
|
1215
|
-
* {
|
|
1216
|
-
* helpers: {
|
|
1217
|
-
* Playwright: {...},
|
|
1218
|
-
* ExpectHelper: {},
|
|
1219
|
-
* }
|
|
1220
|
-
* }
|
|
1221
|
-
* ```
|
|
1222
|
-
*
|
|
1223
|
-
* ## Methods
|
|
1224
|
-
*/
|
|
1225
|
-
class ExpectHelper {
|
|
1226
|
-
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1227
|
-
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1228
|
-
expectDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1229
|
-
expectNotDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1230
|
-
expectContain(actualValue: any, expectedValueToContain: any, customErrorMsg?: any): void;
|
|
1231
|
-
expectNotContain(actualValue: any, expectedValueToNotContain: any, customErrorMsg?: any): void;
|
|
1232
|
-
expectStartsWith(actualValue: any, expectedValueToStartWith: any, customErrorMsg?: any): void;
|
|
1233
|
-
expectNotStartsWith(actualValue: any, expectedValueToNotStartWith: any, customErrorMsg?: any): void;
|
|
1234
|
-
expectEndsWith(actualValue: any, expectedValueToEndWith: any, customErrorMsg?: any): void;
|
|
1235
|
-
expectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg?: any): void;
|
|
1236
|
-
expectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg?: any): void;
|
|
1237
|
-
/**
|
|
1238
|
-
* @param [ajvOptions] - Pass AJV options
|
|
1239
|
-
*/
|
|
1240
|
-
expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: any, ajvOptions?: any): void;
|
|
1241
|
-
expectHasProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1242
|
-
expectHasAProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1243
|
-
expectToBeA(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1244
|
-
expectToBeAn(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1245
|
-
expectMatchRegex(targetData: any, regex: any, customErrorMsg?: any): void;
|
|
1246
|
-
expectLengthOf(targetData: any, length: any, customErrorMsg?: any): void;
|
|
1247
|
-
expectEmpty(targetData: any, customErrorMsg?: any): void;
|
|
1248
|
-
expectTrue(targetData: any, customErrorMsg?: any): void;
|
|
1249
|
-
expectFalse(targetData: any, customErrorMsg?: any): void;
|
|
1250
|
-
expectAbove(targetData: any, aboveThan: any, customErrorMsg?: any): void;
|
|
1251
|
-
expectBelow(targetData: any, belowThan: any, customErrorMsg?: any): void;
|
|
1252
|
-
expectLengthAboveThan(targetData: any, lengthAboveThan: any, customErrorMsg?: any): void;
|
|
1253
|
-
expectLengthBelowThan(targetData: any, lengthBelowThan: any, customErrorMsg?: any): void;
|
|
1254
|
-
expectEqualIgnoreCase(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1255
|
-
/**
|
|
1256
|
-
* expects members of two arrays are deeply equal
|
|
1257
|
-
*/
|
|
1258
|
-
expectDeepMembers(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1259
|
-
/**
|
|
1260
|
-
* expects an array to be a superset of another array
|
|
1261
|
-
*/
|
|
1262
|
-
expectDeepIncludeMembers(superset: any, set: any, customErrorMsg?: any): void;
|
|
1263
|
-
/**
|
|
1264
|
-
* expects members of two JSON objects are deeply equal excluding some properties
|
|
1265
|
-
*/
|
|
1266
|
-
expectDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude: any, customErrorMsg?: any): void;
|
|
1267
|
-
/**
|
|
1268
|
-
* expects a JSON object matches a provided pattern
|
|
1269
|
-
*/
|
|
1270
|
-
expectMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg?: any): void;
|
|
1271
|
-
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1272
|
-
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1273
|
-
expectDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1274
|
-
expectNotDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1275
|
-
expectContain(actualValue: any, expectedValueToContain: any, customErrorMsg?: any): void;
|
|
1276
|
-
expectNotContain(actualValue: any, expectedValueToNotContain: any, customErrorMsg?: any): void;
|
|
1277
|
-
expectStartsWith(actualValue: any, expectedValueToStartWith: any, customErrorMsg?: any): void;
|
|
1278
|
-
expectNotStartsWith(actualValue: any, expectedValueToNotStartWith: any, customErrorMsg?: any): void;
|
|
1279
|
-
expectEndsWith(actualValue: any, expectedValueToEndWith: any, customErrorMsg?: any): void;
|
|
1280
|
-
expectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg?: any): void;
|
|
1281
|
-
expectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg?: any): void;
|
|
1282
|
-
/**
|
|
1283
|
-
* @param [ajvOptions] - Pass AJV options
|
|
1284
|
-
*/
|
|
1285
|
-
expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: any, ajvOptions?: any): void;
|
|
1286
|
-
expectHasProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1287
|
-
expectHasAProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1288
|
-
expectToBeA(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1289
|
-
expectToBeAn(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1290
|
-
expectMatchRegex(targetData: any, regex: any, customErrorMsg?: any): void;
|
|
1291
|
-
expectLengthOf(targetData: any, length: any, customErrorMsg?: any): void;
|
|
1292
|
-
expectEmpty(targetData: any, customErrorMsg?: any): void;
|
|
1293
|
-
expectTrue(targetData: any, customErrorMsg?: any): void;
|
|
1294
|
-
expectFalse(targetData: any, customErrorMsg?: any): void;
|
|
1295
|
-
expectAbove(targetData: any, aboveThan: any, customErrorMsg?: any): void;
|
|
1296
|
-
expectBelow(targetData: any, belowThan: any, customErrorMsg?: any): void;
|
|
1297
|
-
expectLengthAboveThan(targetData: any, lengthAboveThan: any, customErrorMsg?: any): void;
|
|
1298
|
-
expectLengthBelowThan(targetData: any, lengthBelowThan: any, customErrorMsg?: any): void;
|
|
1299
|
-
expectEqualIgnoreCase(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1300
|
-
/**
|
|
1301
|
-
* expects members of two arrays are deeply equal
|
|
1302
|
-
*/
|
|
1303
|
-
expectDeepMembers(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1304
|
-
/**
|
|
1305
|
-
* expects an array to be a superset of another array
|
|
1306
|
-
*/
|
|
1307
|
-
expectDeepIncludeMembers(superset: any, set: any, customErrorMsg?: any): void;
|
|
1308
|
-
/**
|
|
1309
|
-
* expects members of two JSON objects are deeply equal excluding some properties
|
|
1310
|
-
*/
|
|
1311
|
-
expectDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude: any, customErrorMsg?: any): void;
|
|
1312
|
-
/**
|
|
1313
|
-
* expects a JSON object matches a provided pattern
|
|
1314
|
-
*/
|
|
1315
|
-
expectMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg?: any): void;
|
|
1316
|
-
}
|
|
1317
|
-
/**
|
|
1318
|
-
* This helper allows performing assertions based on Chai.
|
|
1319
|
-
*
|
|
1320
|
-
* ### Examples
|
|
1321
|
-
*
|
|
1322
|
-
* Zero-configuration when paired with other helpers like REST, Playwright:
|
|
1323
|
-
*
|
|
1324
|
-
* ```js
|
|
1325
|
-
* // inside codecept.conf.js
|
|
1326
|
-
* {
|
|
1327
|
-
* helpers: {
|
|
1328
|
-
* Playwright: {...},
|
|
1329
|
-
* ExpectHelper: {},
|
|
1330
|
-
* }
|
|
1331
|
-
* }
|
|
1332
|
-
* ```
|
|
1333
|
-
*
|
|
1334
|
-
* ## Methods
|
|
1335
|
-
*/
|
|
1336
|
-
class ExpectHelper {
|
|
1337
|
-
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1338
|
-
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1339
|
-
expectDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1340
|
-
expectNotDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1341
|
-
expectContain(actualValue: any, expectedValueToContain: any, customErrorMsg?: any): void;
|
|
1342
|
-
expectNotContain(actualValue: any, expectedValueToNotContain: any, customErrorMsg?: any): void;
|
|
1343
|
-
expectStartsWith(actualValue: any, expectedValueToStartWith: any, customErrorMsg?: any): void;
|
|
1344
|
-
expectNotStartsWith(actualValue: any, expectedValueToNotStartWith: any, customErrorMsg?: any): void;
|
|
1345
|
-
expectEndsWith(actualValue: any, expectedValueToEndWith: any, customErrorMsg?: any): void;
|
|
1346
|
-
expectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg?: any): void;
|
|
1347
|
-
expectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg?: any): void;
|
|
1348
|
-
/**
|
|
1349
|
-
* @param [ajvOptions] - Pass AJV options
|
|
1350
|
-
*/
|
|
1351
|
-
expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: any, ajvOptions?: any): void;
|
|
1352
|
-
expectHasProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1353
|
-
expectHasAProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1354
|
-
expectToBeA(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1355
|
-
expectToBeAn(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1356
|
-
expectMatchRegex(targetData: any, regex: any, customErrorMsg?: any): void;
|
|
1357
|
-
expectLengthOf(targetData: any, length: any, customErrorMsg?: any): void;
|
|
1358
|
-
expectEmpty(targetData: any, customErrorMsg?: any): void;
|
|
1359
|
-
expectTrue(targetData: any, customErrorMsg?: any): void;
|
|
1360
|
-
expectFalse(targetData: any, customErrorMsg?: any): void;
|
|
1361
|
-
expectAbove(targetData: any, aboveThan: any, customErrorMsg?: any): void;
|
|
1362
|
-
expectBelow(targetData: any, belowThan: any, customErrorMsg?: any): void;
|
|
1363
|
-
expectLengthAboveThan(targetData: any, lengthAboveThan: any, customErrorMsg?: any): void;
|
|
1364
|
-
expectLengthBelowThan(targetData: any, lengthBelowThan: any, customErrorMsg?: any): void;
|
|
1365
|
-
expectEqualIgnoreCase(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1366
|
-
/**
|
|
1367
|
-
* expects members of two arrays are deeply equal
|
|
1368
|
-
*/
|
|
1369
|
-
expectDeepMembers(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1370
|
-
/**
|
|
1371
|
-
* expects an array to be a superset of another array
|
|
1372
|
-
*/
|
|
1373
|
-
expectDeepIncludeMembers(superset: any, set: any, customErrorMsg?: any): void;
|
|
1374
|
-
/**
|
|
1375
|
-
* expects members of two JSON objects are deeply equal excluding some properties
|
|
1376
|
-
*/
|
|
1377
|
-
expectDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude: any, customErrorMsg?: any): void;
|
|
1378
|
-
/**
|
|
1379
|
-
* expects a JSON object matches a provided pattern
|
|
1380
|
-
*/
|
|
1381
|
-
expectMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg?: any): void;
|
|
1382
|
-
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1383
|
-
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1384
|
-
expectDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1385
|
-
expectNotDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1386
|
-
expectContain(actualValue: any, expectedValueToContain: any, customErrorMsg?: any): void;
|
|
1387
|
-
expectNotContain(actualValue: any, expectedValueToNotContain: any, customErrorMsg?: any): void;
|
|
1388
|
-
expectStartsWith(actualValue: any, expectedValueToStartWith: any, customErrorMsg?: any): void;
|
|
1389
|
-
expectNotStartsWith(actualValue: any, expectedValueToNotStartWith: any, customErrorMsg?: any): void;
|
|
1390
|
-
expectEndsWith(actualValue: any, expectedValueToEndWith: any, customErrorMsg?: any): void;
|
|
1391
|
-
expectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg?: any): void;
|
|
1392
|
-
expectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg?: any): void;
|
|
1393
|
-
/**
|
|
1394
|
-
* @param [ajvOptions] - Pass AJV options
|
|
1395
|
-
*/
|
|
1396
|
-
expectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: any, ajvOptions?: any): void;
|
|
1397
|
-
expectHasProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1398
|
-
expectHasAProperty(targetData: any, propertyName: any, customErrorMsg?: any): void;
|
|
1399
|
-
expectToBeA(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1400
|
-
expectToBeAn(targetData: any, type: any, customErrorMsg?: any): void;
|
|
1401
|
-
expectMatchRegex(targetData: any, regex: any, customErrorMsg?: any): void;
|
|
1402
|
-
expectLengthOf(targetData: any, length: any, customErrorMsg?: any): void;
|
|
1403
|
-
expectEmpty(targetData: any, customErrorMsg?: any): void;
|
|
1404
|
-
expectTrue(targetData: any, customErrorMsg?: any): void;
|
|
1405
|
-
expectFalse(targetData: any, customErrorMsg?: any): void;
|
|
1406
|
-
expectAbove(targetData: any, aboveThan: any, customErrorMsg?: any): void;
|
|
1407
|
-
expectBelow(targetData: any, belowThan: any, customErrorMsg?: any): void;
|
|
1408
|
-
expectLengthAboveThan(targetData: any, lengthAboveThan: any, customErrorMsg?: any): void;
|
|
1409
|
-
expectLengthBelowThan(targetData: any, lengthBelowThan: any, customErrorMsg?: any): void;
|
|
1410
|
-
expectEqualIgnoreCase(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1411
|
-
/**
|
|
1412
|
-
* expects members of two arrays are deeply equal
|
|
1413
|
-
*/
|
|
1414
|
-
expectDeepMembers(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1415
|
-
/**
|
|
1416
|
-
* expects an array to be a superset of another array
|
|
1417
|
-
*/
|
|
1418
|
-
expectDeepIncludeMembers(superset: any, set: any, customErrorMsg?: any): void;
|
|
1419
|
-
/**
|
|
1420
|
-
* expects members of two JSON objects are deeply equal excluding some properties
|
|
1421
|
-
*/
|
|
1422
|
-
expectDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude: any, customErrorMsg?: any): void;
|
|
1423
|
-
/**
|
|
1424
|
-
* expects a JSON object matches a provided pattern
|
|
1425
|
-
*/
|
|
1426
|
-
expectMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg?: any): void;
|
|
1427
|
-
}
|
|
1428
1206
|
/**
|
|
1429
1207
|
* Helper for testing filesystem.
|
|
1430
1208
|
* Can be easily used to check file structures:
|
|
@@ -2000,191 +1778,6 @@ declare namespace CodeceptJS {
|
|
|
2000
1778
|
*/
|
|
2001
1779
|
seeResponseMatchesJsonSchema(fnOrSchema: any): void;
|
|
2002
1780
|
}
|
|
2003
|
-
/**
|
|
2004
|
-
* ## Configuration
|
|
2005
|
-
*
|
|
2006
|
-
* This helper should be configured in codecept.conf.(js|ts)
|
|
2007
|
-
* @property [port = 9393] - Mock server port
|
|
2008
|
-
* @property [host = "0.0.0.0"] - Mock server host
|
|
2009
|
-
* @property [httpsOpts] - key & cert values are the paths to .key and .crt files
|
|
2010
|
-
*/
|
|
2011
|
-
type MockServerConfig = {
|
|
2012
|
-
port?: number;
|
|
2013
|
-
host?: string;
|
|
2014
|
-
httpsOpts?: any;
|
|
2015
|
-
};
|
|
2016
|
-
/**
|
|
2017
|
-
* MockServer
|
|
2018
|
-
*
|
|
2019
|
-
* 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.
|
|
2020
|
-
*
|
|
2021
|
-
* <!-- configuration -->
|
|
2022
|
-
*
|
|
2023
|
-
* #### Examples
|
|
2024
|
-
*
|
|
2025
|
-
* You can seamlessly integrate MockServer with other helpers like REST or Playwright. Here's a configuration example inside the `codecept.conf.js` file:
|
|
2026
|
-
*
|
|
2027
|
-
* ```javascript
|
|
2028
|
-
* {
|
|
2029
|
-
* helpers: {
|
|
2030
|
-
* REST: {...},
|
|
2031
|
-
* MockServer: {
|
|
2032
|
-
* // default mock server config
|
|
2033
|
-
* port: 9393,
|
|
2034
|
-
* host: '0.0.0.0',
|
|
2035
|
-
* httpsOpts: {
|
|
2036
|
-
* key: '',
|
|
2037
|
-
* cert: '',
|
|
2038
|
-
* },
|
|
2039
|
-
* },
|
|
2040
|
-
* }
|
|
2041
|
-
* }
|
|
2042
|
-
* ```
|
|
2043
|
-
*
|
|
2044
|
-
* #### Adding Interactions
|
|
2045
|
-
*
|
|
2046
|
-
* 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.
|
|
2047
|
-
*
|
|
2048
|
-
* ```javascript
|
|
2049
|
-
* I.addInteractionToMockServer({
|
|
2050
|
-
* request: {
|
|
2051
|
-
* method: 'GET',
|
|
2052
|
-
* path: '/api/hello'
|
|
2053
|
-
* },
|
|
2054
|
-
* response: {
|
|
2055
|
-
* status: 200,
|
|
2056
|
-
* body: {
|
|
2057
|
-
* 'say': 'hello to mock server'
|
|
2058
|
-
* }
|
|
2059
|
-
* }
|
|
2060
|
-
* });
|
|
2061
|
-
* ```
|
|
2062
|
-
*
|
|
2063
|
-
* #### Request Matching
|
|
2064
|
-
*
|
|
2065
|
-
* 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.
|
|
2066
|
-
*
|
|
2067
|
-
* - Strong match on HTTP Method, Path, Query Params & JSON body.
|
|
2068
|
-
* - Loose match on Headers.
|
|
2069
|
-
*
|
|
2070
|
-
* ##### Strong Match on Query Params
|
|
2071
|
-
*
|
|
2072
|
-
* You can send different responses based on query parameters:
|
|
2073
|
-
*
|
|
2074
|
-
* ```javascript
|
|
2075
|
-
* I.addInteractionToMockServer({
|
|
2076
|
-
* request: {
|
|
2077
|
-
* method: 'GET',
|
|
2078
|
-
* path: '/api/users',
|
|
2079
|
-
* queryParams: {
|
|
2080
|
-
* id: 1
|
|
2081
|
-
* }
|
|
2082
|
-
* },
|
|
2083
|
-
* response: {
|
|
2084
|
-
* status: 200,
|
|
2085
|
-
* body: 'user 1'
|
|
2086
|
-
* }
|
|
2087
|
-
* });
|
|
2088
|
-
*
|
|
2089
|
-
* I.addInteractionToMockServer({
|
|
2090
|
-
* request: {
|
|
2091
|
-
* method: 'GET',
|
|
2092
|
-
* path: '/api/users',
|
|
2093
|
-
* queryParams: {
|
|
2094
|
-
* id: 2
|
|
2095
|
-
* }
|
|
2096
|
-
* },
|
|
2097
|
-
* response: {
|
|
2098
|
-
* status: 200,
|
|
2099
|
-
* body: 'user 2'
|
|
2100
|
-
* }
|
|
2101
|
-
* });
|
|
2102
|
-
* ```
|
|
2103
|
-
*
|
|
2104
|
-
* - GET to `/api/users?id=1` will return 'user 1'.
|
|
2105
|
-
* - GET to `/api/users?id=2` will return 'user 2'.
|
|
2106
|
-
* - For all other requests, it returns a 404 status code.
|
|
2107
|
-
*
|
|
2108
|
-
* ##### Loose Match on Body
|
|
2109
|
-
*
|
|
2110
|
-
* When `strict` is set to false, it performs a loose match on query params and response body:
|
|
2111
|
-
*
|
|
2112
|
-
* ```javascript
|
|
2113
|
-
* I.addInteractionToMockServer({
|
|
2114
|
-
* strict: false,
|
|
2115
|
-
* request: {
|
|
2116
|
-
* method: 'POST',
|
|
2117
|
-
* path: '/api/users',
|
|
2118
|
-
* body: {
|
|
2119
|
-
* name: 'john'
|
|
2120
|
-
* }
|
|
2121
|
-
* },
|
|
2122
|
-
* response: {
|
|
2123
|
-
* status: 200
|
|
2124
|
-
* }
|
|
2125
|
-
* });
|
|
2126
|
-
* ```
|
|
2127
|
-
*
|
|
2128
|
-
* - POST to `/api/users` with the body containing `name` as 'john' will return a 200 status code.
|
|
2129
|
-
* - POST to `/api/users` without the `name` property in the body will return a 404 status code.
|
|
2130
|
-
*
|
|
2131
|
-
* Happy testing with MockServer in CodeceptJS! 🚀
|
|
2132
|
-
*
|
|
2133
|
-
* ## Methods
|
|
2134
|
-
*/
|
|
2135
|
-
class MockServer {
|
|
2136
|
-
/**
|
|
2137
|
-
* Start the mock server
|
|
2138
|
-
* @param [port] - start the mock server with given port
|
|
2139
|
-
* @returns void
|
|
2140
|
-
*/
|
|
2141
|
-
startMockServer(port?: number): any;
|
|
2142
|
-
/**
|
|
2143
|
-
* Stop the mock server
|
|
2144
|
-
* @returns void
|
|
2145
|
-
*/
|
|
2146
|
-
stopMockServer(): any;
|
|
2147
|
-
/**
|
|
2148
|
-
* An interaction adds behavior to the mock server
|
|
2149
|
-
*
|
|
2150
|
-
*
|
|
2151
|
-
* ```js
|
|
2152
|
-
* I.addInteractionToMockServer({
|
|
2153
|
-
* request: {
|
|
2154
|
-
* method: 'GET',
|
|
2155
|
-
* path: '/api/hello'
|
|
2156
|
-
* },
|
|
2157
|
-
* response: {
|
|
2158
|
-
* status: 200,
|
|
2159
|
-
* body: {
|
|
2160
|
-
* 'say': 'hello to mock server'
|
|
2161
|
-
* }
|
|
2162
|
-
* }
|
|
2163
|
-
* });
|
|
2164
|
-
* ```
|
|
2165
|
-
* ```js
|
|
2166
|
-
* // with query params
|
|
2167
|
-
* I.addInteractionToMockServer({
|
|
2168
|
-
* request: {
|
|
2169
|
-
* method: 'GET',
|
|
2170
|
-
* path: '/api/hello',
|
|
2171
|
-
* queryParams: {
|
|
2172
|
-
* id: 2
|
|
2173
|
-
* }
|
|
2174
|
-
* },
|
|
2175
|
-
* response: {
|
|
2176
|
-
* status: 200,
|
|
2177
|
-
* body: {
|
|
2178
|
-
* 'say': 'hello to mock server'
|
|
2179
|
-
* }
|
|
2180
|
-
* }
|
|
2181
|
-
* });
|
|
2182
|
-
* ```
|
|
2183
|
-
* @param interaction - add behavior to the mock server
|
|
2184
|
-
* @returns void
|
|
2185
|
-
*/
|
|
2186
|
-
addInteractionToMockServer(interaction: CodeceptJS.MockInteraction | any): any;
|
|
2187
|
-
}
|
|
2188
1781
|
/**
|
|
2189
1782
|
* Nightmare helper wraps [Nightmare](https://github.com/segmentio/nightmare) library to provide
|
|
2190
1783
|
* fastest headless testing using Electron engine. Unlike Selenium-based drivers this uses
|
|
@@ -3187,46 +2780,6 @@ declare namespace CodeceptJS {
|
|
|
3187
2780
|
*/
|
|
3188
2781
|
grabPageScrollPosition(): Promise<PageScrollPosition>;
|
|
3189
2782
|
}
|
|
3190
|
-
/**
|
|
3191
|
-
* OpenAI Helper for CodeceptJS.
|
|
3192
|
-
*
|
|
3193
|
-
* This helper class provides integration with the OpenAI GPT-3.5 or 4 language model for generating responses to questions or prompts within the context of web pages. It allows you to interact with the GPT-3.5 model to obtain intelligent responses based on HTML fragments or general prompts.
|
|
3194
|
-
* This helper should be enabled with any web helpers like Playwright or Puppeteer or WebDrvier to ensure the HTML context is available.
|
|
3195
|
-
*
|
|
3196
|
-
* ## Configuration
|
|
3197
|
-
*
|
|
3198
|
-
* This helper should be configured in codecept.json or codecept.conf.js
|
|
3199
|
-
*
|
|
3200
|
-
* * `chunkSize`: (optional, default: 80000) - The maximum number of characters to send to the OpenAI API at once. We split HTML fragments by 8000 chars to not exceed token limit. Increase this value if you use GPT-4.
|
|
3201
|
-
*/
|
|
3202
|
-
class OpenAI {
|
|
3203
|
-
/**
|
|
3204
|
-
* Asks the OpenAI GPT language model a question based on the provided prompt within the context of the current page's HTML.
|
|
3205
|
-
*
|
|
3206
|
-
* ```js
|
|
3207
|
-
* I.askGptOnPage('what does this page do?');
|
|
3208
|
-
* ```
|
|
3209
|
-
* @param prompt - The question or prompt to ask the GPT model.
|
|
3210
|
-
* @returns - A Promise that resolves to the generated responses from the GPT model, joined by newlines.
|
|
3211
|
-
*/
|
|
3212
|
-
askGptOnPage(prompt: string): Promise<string>;
|
|
3213
|
-
/**
|
|
3214
|
-
* Asks the OpenAI GPT-3.5 language model a question based on the provided prompt within the context of a specific HTML fragment on the current page.
|
|
3215
|
-
*
|
|
3216
|
-
* ```js
|
|
3217
|
-
* I.askGptOnPageFragment('describe features of this screen', '.screen');
|
|
3218
|
-
* ```
|
|
3219
|
-
* @param prompt - The question or prompt to ask the GPT-3.5 model.
|
|
3220
|
-
* @param locator - The locator or selector used to identify the HTML fragment on the page.
|
|
3221
|
-
* @returns - A Promise that resolves to the generated response from the GPT model.
|
|
3222
|
-
*/
|
|
3223
|
-
askGptOnPageFragment(prompt: string, locator: string): Promise<string>;
|
|
3224
|
-
/**
|
|
3225
|
-
* Send a general request to ChatGPT and return response.
|
|
3226
|
-
* @returns - A Promise that resolves to the generated response from the GPT model.
|
|
3227
|
-
*/
|
|
3228
|
-
askGptGeneralPrompt(prompt: string): Promise<string>;
|
|
3229
|
-
}
|
|
3230
2783
|
/**
|
|
3231
2784
|
* ## Configuration
|
|
3232
2785
|
*
|
|
@@ -3271,6 +2824,7 @@ declare namespace CodeceptJS {
|
|
|
3271
2824
|
* @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).
|
|
3272
2825
|
* @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).
|
|
3273
2826
|
*/
|
|
2827
|
+
// @ts-ignore
|
|
3274
2828
|
type PlaywrightConfig = {
|
|
3275
2829
|
url?: string;
|
|
3276
2830
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6798,6 +6352,7 @@ declare namespace CodeceptJS {
|
|
|
6798
6352
|
* @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
|
|
6799
6353
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
6800
6354
|
*/
|
|
6355
|
+
// @ts-ignore
|
|
6801
6356
|
type PuppeteerConfig = {
|
|
6802
6357
|
url: string;
|
|
6803
6358
|
basicAuth?: any;
|
|
@@ -7237,6 +6792,17 @@ declare namespace CodeceptJS {
|
|
|
7237
6792
|
* {{ react }}
|
|
7238
6793
|
*/
|
|
7239
6794
|
_locate(): void;
|
|
6795
|
+
/**
|
|
6796
|
+
* Get single element by different locator types, including strict locator
|
|
6797
|
+
* Should be used in custom helpers:
|
|
6798
|
+
*
|
|
6799
|
+
* ```js
|
|
6800
|
+
* const element = await this.helpers['Puppeteer']._locateElement({name: 'password'});
|
|
6801
|
+
* ```
|
|
6802
|
+
*
|
|
6803
|
+
* {{ react }}
|
|
6804
|
+
*/
|
|
6805
|
+
_locateElement(): void;
|
|
7240
6806
|
/**
|
|
7241
6807
|
* Find a checkbox by providing human-readable text:
|
|
7242
6808
|
* NOTE: Assumes the checkable element exists
|
|
@@ -7273,6 +6839,17 @@ declare namespace CodeceptJS {
|
|
|
7273
6839
|
* @returns WebElement of being used Web helper
|
|
7274
6840
|
*/
|
|
7275
6841
|
grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
6842
|
+
/**
|
|
6843
|
+
* Grab WebElement for given locator
|
|
6844
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
6845
|
+
*
|
|
6846
|
+
* ```js
|
|
6847
|
+
* const webElement = await I.grabWebElement('#button');
|
|
6848
|
+
* ```
|
|
6849
|
+
* @param locator - element located by CSS|XPath|strict locator.
|
|
6850
|
+
* @returns WebElement of being used Web helper
|
|
6851
|
+
*/
|
|
6852
|
+
grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
7276
6853
|
/**
|
|
7277
6854
|
* Switch focus to a particular tab by its number. It waits tabs loading and then switch tab
|
|
7278
6855
|
*
|
|
@@ -8728,6 +8305,22 @@ declare namespace CodeceptJS {
|
|
|
8728
8305
|
*/
|
|
8729
8306
|
flushWebSocketMessages(): void;
|
|
8730
8307
|
}
|
|
8308
|
+
/**
|
|
8309
|
+
* Find elements using Puppeteer's native element discovery methods
|
|
8310
|
+
* Note: Unlike Playwright, Puppeteer's Locator API doesn't have .all() method for multiple elements
|
|
8311
|
+
* @param matcher - Puppeteer context to search within
|
|
8312
|
+
* @param locator - Locator specification
|
|
8313
|
+
* @returns Array of ElementHandle objects
|
|
8314
|
+
*/
|
|
8315
|
+
function findElements(matcher: any, locator: any | string): Promise<any[]>;
|
|
8316
|
+
/**
|
|
8317
|
+
* Find a single element using Puppeteer's native element discovery methods
|
|
8318
|
+
* Note: Puppeteer Locator API doesn't have .first() method like Playwright
|
|
8319
|
+
* @param matcher - Puppeteer context to search within
|
|
8320
|
+
* @param locator - Locator specification
|
|
8321
|
+
* @returns Single ElementHandle object
|
|
8322
|
+
*/
|
|
8323
|
+
function findElement(matcher: any, locator: any | string): Promise<object>;
|
|
8731
8324
|
/**
|
|
8732
8325
|
* ## Configuration
|
|
8733
8326
|
* @property [endpoint] - API base URL
|
|
@@ -8740,6 +8333,7 @@ declare namespace CodeceptJS {
|
|
|
8740
8333
|
* @property [onResponse] - an async function which can update response object.
|
|
8741
8334
|
* @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
8742
8335
|
*/
|
|
8336
|
+
// @ts-ignore
|
|
8743
8337
|
type RESTConfig = {
|
|
8744
8338
|
endpoint?: string;
|
|
8745
8339
|
prettyPrintJson?: boolean;
|
|
@@ -8932,250 +8526,6 @@ declare namespace CodeceptJS {
|
|
|
8932
8526
|
*/
|
|
8933
8527
|
sendDeleteRequestWithPayload(url: any, payload?: any, headers?: any): Promise<any>;
|
|
8934
8528
|
}
|
|
8935
|
-
/**
|
|
8936
|
-
* SoftAssertHelper is a utility class for performing soft assertions.
|
|
8937
|
-
* Unlike traditional assertions that stop the execution on failure,
|
|
8938
|
-
* soft assertions allow the execution to continue and report all failures at the end.
|
|
8939
|
-
*
|
|
8940
|
-
* ### Examples
|
|
8941
|
-
*
|
|
8942
|
-
* Zero-configuration when paired with other helpers like REST, Playwright:
|
|
8943
|
-
*
|
|
8944
|
-
* ```js
|
|
8945
|
-
* // inside codecept.conf.js
|
|
8946
|
-
* {
|
|
8947
|
-
* helpers: {
|
|
8948
|
-
* Playwright: {...},
|
|
8949
|
-
* SoftExpectHelper: {},
|
|
8950
|
-
* }
|
|
8951
|
-
* }
|
|
8952
|
-
* ```
|
|
8953
|
-
*
|
|
8954
|
-
* ```js
|
|
8955
|
-
* // in scenario
|
|
8956
|
-
* I.softExpectEqual('a', 'b')
|
|
8957
|
-
* I.flushSoftAssertions() // Throws an error if any soft assertions have failed. The error message contains all the accumulated failures.
|
|
8958
|
-
* ```
|
|
8959
|
-
*
|
|
8960
|
-
* ## Methods
|
|
8961
|
-
*/
|
|
8962
|
-
class SoftAssertHelper {
|
|
8963
|
-
/**
|
|
8964
|
-
* Performs a soft assertion by executing the provided assertion function.
|
|
8965
|
-
* If the assertion fails, the error is caught and stored without halting the execution.
|
|
8966
|
-
* @param assertionFn - The assertion function to execute.
|
|
8967
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
8968
|
-
*/
|
|
8969
|
-
softAssert(assertionFn: (...params: any[]) => any, customErrorMsg?: string): void;
|
|
8970
|
-
/**
|
|
8971
|
-
* Throws an error if any soft assertions have failed.
|
|
8972
|
-
* The error message contains all the accumulated failures.
|
|
8973
|
-
*/
|
|
8974
|
-
flushSoftAssertions(): void;
|
|
8975
|
-
/**
|
|
8976
|
-
* Softly asserts that two values are equal.
|
|
8977
|
-
* @param actualValue - The actual value.
|
|
8978
|
-
* @param expectedValue - The expected value.
|
|
8979
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
8980
|
-
*/
|
|
8981
|
-
softExpectEqual(actualValue: any, expectedValue: any, customErrorMsg?: string): void;
|
|
8982
|
-
/**
|
|
8983
|
-
* Softly asserts that two values are not equal.
|
|
8984
|
-
* @param actualValue - The actual value.
|
|
8985
|
-
* @param expectedValue - The expected value.
|
|
8986
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
8987
|
-
*/
|
|
8988
|
-
softExpectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: string): void;
|
|
8989
|
-
/**
|
|
8990
|
-
* Softly asserts that two values are deeply equal.
|
|
8991
|
-
* @param actualValue - The actual value.
|
|
8992
|
-
* @param expectedValue - The expected value.
|
|
8993
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
8994
|
-
*/
|
|
8995
|
-
softExpectDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: string): void;
|
|
8996
|
-
/**
|
|
8997
|
-
* Softly asserts that two values are not deeply equal.
|
|
8998
|
-
* @param actualValue - The actual value.
|
|
8999
|
-
* @param expectedValue - The expected value.
|
|
9000
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9001
|
-
*/
|
|
9002
|
-
softExpectNotDeepEqual(actualValue: any, expectedValue: any, customErrorMsg?: string): void;
|
|
9003
|
-
/**
|
|
9004
|
-
* Softly asserts that a value contains the expected value.
|
|
9005
|
-
* @param actualValue - The actual value.
|
|
9006
|
-
* @param expectedValueToContain - The value that should be contained within the actual value.
|
|
9007
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9008
|
-
*/
|
|
9009
|
-
softExpectContain(actualValue: any, expectedValueToContain: any, customErrorMsg?: string): void;
|
|
9010
|
-
/**
|
|
9011
|
-
* Softly asserts that a value does not contain the expected value.
|
|
9012
|
-
* @param actualValue - The actual value.
|
|
9013
|
-
* @param expectedValueToNotContain - The value that should not be contained within the actual value.
|
|
9014
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9015
|
-
*/
|
|
9016
|
-
softExpectNotContain(actualValue: any, expectedValueToNotContain: any, customErrorMsg?: string): void;
|
|
9017
|
-
/**
|
|
9018
|
-
* Softly asserts that a value starts with the expected value.
|
|
9019
|
-
* @param actualValue - The actual value.
|
|
9020
|
-
* @param expectedValueToStartWith - The value that the actual value should start with.
|
|
9021
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9022
|
-
*/
|
|
9023
|
-
softExpectStartsWith(actualValue: any, expectedValueToStartWith: any, customErrorMsg?: string): void;
|
|
9024
|
-
/**
|
|
9025
|
-
* Softly asserts that a value does not start with the expected value.
|
|
9026
|
-
* @param actualValue - The actual value.
|
|
9027
|
-
* @param expectedValueToNotStartWith - The value that the actual value should not start with.
|
|
9028
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9029
|
-
*/
|
|
9030
|
-
softExpectNotStartsWith(actualValue: any, expectedValueToNotStartWith: any, customErrorMsg?: string): void;
|
|
9031
|
-
/**
|
|
9032
|
-
* Softly asserts that a value ends with the expected value.
|
|
9033
|
-
* @param actualValue - The actual value.
|
|
9034
|
-
* @param expectedValueToEndWith - The value that the actual value should end with.
|
|
9035
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9036
|
-
*/
|
|
9037
|
-
softExpectEndsWith(actualValue: any, expectedValueToEndWith: any, customErrorMsg?: string): void;
|
|
9038
|
-
/**
|
|
9039
|
-
* Softly asserts that a value does not end with the expected value.
|
|
9040
|
-
* @param actualValue - The actual value.
|
|
9041
|
-
* @param expectedValueToNotEndWith - The value that the actual value should not end with.
|
|
9042
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9043
|
-
*/
|
|
9044
|
-
softExpectNotEndsWith(actualValue: any, expectedValueToNotEndWith: any, customErrorMsg?: string): void;
|
|
9045
|
-
/**
|
|
9046
|
-
* Softly asserts that the target data matches the given JSON schema.
|
|
9047
|
-
* @param targetData - The data to validate.
|
|
9048
|
-
* @param jsonSchema - The JSON schema to validate against.
|
|
9049
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9050
|
-
*/
|
|
9051
|
-
softExpectJsonSchema(targetData: any, jsonSchema: any, customErrorMsg?: string): void;
|
|
9052
|
-
/**
|
|
9053
|
-
* Softly asserts that the target data matches the given JSON schema using AJV.
|
|
9054
|
-
* @param targetData - The data to validate.
|
|
9055
|
-
* @param jsonSchema - The JSON schema to validate against.
|
|
9056
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9057
|
-
* @param [ajvOptions = { allErrors: true }] - Options to pass to AJV.
|
|
9058
|
-
*/
|
|
9059
|
-
softExpectJsonSchemaUsingAJV(targetData: any, jsonSchema: any, customErrorMsg?: string, ajvOptions?: any): void;
|
|
9060
|
-
/**
|
|
9061
|
-
* Softly asserts that the target data has the specified property.
|
|
9062
|
-
* @param targetData - The data to check.
|
|
9063
|
-
* @param propertyName - The property name to check for.
|
|
9064
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion
|
|
9065
|
-
* fails.
|
|
9066
|
-
*/
|
|
9067
|
-
softExpectHasProperty(targetData: any, propertyName: string, customErrorMsg?: string): void;
|
|
9068
|
-
/**
|
|
9069
|
-
* Softly asserts that the target data has a property with the specified name.
|
|
9070
|
-
* @param targetData - The data to check.
|
|
9071
|
-
* @param propertyName - The property name to check for.
|
|
9072
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9073
|
-
*/
|
|
9074
|
-
softExpectHasAProperty(targetData: any, propertyName: string, customErrorMsg?: string): void;
|
|
9075
|
-
/**
|
|
9076
|
-
* Softly asserts that the target data is of a specific type.
|
|
9077
|
-
* @param targetData - The data to check.
|
|
9078
|
-
* @param type - The expected type (e.g., 'string', 'number').
|
|
9079
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9080
|
-
*/
|
|
9081
|
-
softExpectToBeA(targetData: any, type: string, customErrorMsg?: string): void;
|
|
9082
|
-
/**
|
|
9083
|
-
* Softly asserts that the target data is of a specific type (alternative for articles).
|
|
9084
|
-
* @param targetData - The data to check.
|
|
9085
|
-
* @param type - The expected type (e.g., 'string', 'number').
|
|
9086
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9087
|
-
*/
|
|
9088
|
-
softExpectToBeAn(targetData: any, type: string, customErrorMsg?: string): void;
|
|
9089
|
-
/**
|
|
9090
|
-
* Softly asserts that the target data has a specified length.
|
|
9091
|
-
* @param targetData - The data to check.
|
|
9092
|
-
* @param length - The expected length.
|
|
9093
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9094
|
-
*/
|
|
9095
|
-
softExpectLengthOf(targetData: any, length: number, customErrorMsg?: string): void;
|
|
9096
|
-
/**
|
|
9097
|
-
* Softly asserts that the target data is empty.
|
|
9098
|
-
* @param targetData - The data to check.
|
|
9099
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9100
|
-
*/
|
|
9101
|
-
softExpectEmpty(targetData: any, customErrorMsg?: string): void;
|
|
9102
|
-
/**
|
|
9103
|
-
* Softly asserts that the target data is true.
|
|
9104
|
-
* @param targetData - The data to check.
|
|
9105
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9106
|
-
*/
|
|
9107
|
-
softExpectTrue(targetData: any, customErrorMsg?: string): void;
|
|
9108
|
-
/**
|
|
9109
|
-
* Softly asserts that the target data is false.
|
|
9110
|
-
* @param targetData - The data to check.
|
|
9111
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9112
|
-
*/
|
|
9113
|
-
softExpectFalse(targetData: any, customErrorMsg?: string): void;
|
|
9114
|
-
/**
|
|
9115
|
-
* Softly asserts that the target data is above a specified value.
|
|
9116
|
-
* @param targetData - The data to check.
|
|
9117
|
-
* @param aboveThan - The value that the target data should be above.
|
|
9118
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9119
|
-
*/
|
|
9120
|
-
softExpectAbove(targetData: any, aboveThan: any, customErrorMsg?: string): void;
|
|
9121
|
-
/**
|
|
9122
|
-
* Softly asserts that the target data is below a specified value.
|
|
9123
|
-
* @param targetData - The data to check.
|
|
9124
|
-
* @param belowThan - The value that the target data should be below.
|
|
9125
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9126
|
-
*/
|
|
9127
|
-
softExpectBelow(targetData: any, belowThan: any, customErrorMsg?: string): void;
|
|
9128
|
-
/**
|
|
9129
|
-
* Softly asserts that the length of the target data is above a specified value.
|
|
9130
|
-
* @param targetData - The data to check.
|
|
9131
|
-
* @param lengthAboveThan - The length that the target data should be above.
|
|
9132
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9133
|
-
*/
|
|
9134
|
-
softExpectLengthAboveThan(targetData: any, lengthAboveThan: number, customErrorMsg?: string): void;
|
|
9135
|
-
/**
|
|
9136
|
-
* Softly asserts that the length of the target data is below a specified value.
|
|
9137
|
-
* @param targetData - The data to check.
|
|
9138
|
-
* @param lengthBelowThan - The length that the target data should be below.
|
|
9139
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9140
|
-
*/
|
|
9141
|
-
softExpectLengthBelowThan(targetData: any, lengthBelowThan: number, customErrorMsg?: string): void;
|
|
9142
|
-
/**
|
|
9143
|
-
* Softly asserts that two values are equal, ignoring case.
|
|
9144
|
-
* @param actualValue - The actual string value.
|
|
9145
|
-
* @param expectedValue - The expected string value.
|
|
9146
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9147
|
-
*/
|
|
9148
|
-
softExpectEqualIgnoreCase(actualValue: string, expectedValue: string, customErrorMsg?: string): void;
|
|
9149
|
-
/**
|
|
9150
|
-
* Softly asserts that two arrays have deep equality, considering members in any order.
|
|
9151
|
-
* @param actualValue - The actual array.
|
|
9152
|
-
* @param expectedValue - The expected array.
|
|
9153
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9154
|
-
*/
|
|
9155
|
-
softExpectDeepMembers(actualValue: any[], expectedValue: any[], customErrorMsg?: string): void;
|
|
9156
|
-
/**
|
|
9157
|
-
* Softly asserts that an array (superset) deeply includes all members of another array (set).
|
|
9158
|
-
* @param superset - The array that should contain the expected members.
|
|
9159
|
-
* @param set - The array with members that should be included.
|
|
9160
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9161
|
-
*/
|
|
9162
|
-
softExpectDeepIncludeMembers(superset: any[], set: any[], customErrorMsg?: string): void;
|
|
9163
|
-
/**
|
|
9164
|
-
* Softly asserts that two objects are deeply equal, excluding specified fields.
|
|
9165
|
-
* @param actualValue - The actual object.
|
|
9166
|
-
* @param expectedValue - The expected object.
|
|
9167
|
-
* @param fieldsToExclude - The fields to exclude from the comparison.
|
|
9168
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9169
|
-
*/
|
|
9170
|
-
softExpectDeepEqualExcluding(actualValue: any, expectedValue: any, fieldsToExclude: string[], customErrorMsg?: string): void;
|
|
9171
|
-
/**
|
|
9172
|
-
* Softly asserts that a value matches the expected pattern.
|
|
9173
|
-
* @param actualValue - The actual value.
|
|
9174
|
-
* @param expectedPattern - The pattern the value should match.
|
|
9175
|
-
* @param [customErrorMsg = ''] - A custom error message to display if the assertion fails.
|
|
9176
|
-
*/
|
|
9177
|
-
softExpectMatchesPattern(actualValue: any, expectedPattern: any, customErrorMsg?: string): void;
|
|
9178
|
-
}
|
|
9179
8529
|
/**
|
|
9180
8530
|
* Client Functions
|
|
9181
8531
|
*/
|
|
@@ -10189,6 +9539,7 @@ declare namespace CodeceptJS {
|
|
|
10189
9539
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
10190
9540
|
* @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
|
|
10191
9541
|
*/
|
|
9542
|
+
// @ts-ignore
|
|
10192
9543
|
type WebDriverConfig = {
|
|
10193
9544
|
url: string;
|
|
10194
9545
|
browser: string;
|
|
@@ -10659,6 +10010,17 @@ declare namespace CodeceptJS {
|
|
|
10659
10010
|
* @returns WebElement of being used Web helper
|
|
10660
10011
|
*/
|
|
10661
10012
|
grabWebElements(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
10013
|
+
/**
|
|
10014
|
+
* Grab WebElement for given locator
|
|
10015
|
+
* Resumes test execution, so **should be used inside an async function with `await`** operator.
|
|
10016
|
+
*
|
|
10017
|
+
* ```js
|
|
10018
|
+
* const webElement = await I.grabWebElement('#button');
|
|
10019
|
+
* ```
|
|
10020
|
+
* @param locator - element located by CSS|XPath|strict locator.
|
|
10021
|
+
* @returns WebElement of being used Web helper
|
|
10022
|
+
*/
|
|
10023
|
+
grabWebElement(locator: CodeceptJS.LocatorOrString): Promise<any>;
|
|
10662
10024
|
/**
|
|
10663
10025
|
* Set [WebDriver timeouts](https://webdriver.io/docs/timeouts.html) in realtime.
|
|
10664
10026
|
*
|
|
@@ -12203,6 +11565,13 @@ declare namespace CodeceptJS {
|
|
|
12203
11565
|
* Loads tests by pattern or by config.tests
|
|
12204
11566
|
*/
|
|
12205
11567
|
loadTests(pattern?: string): void;
|
|
11568
|
+
/**
|
|
11569
|
+
* Apply sharding to test files based on shard configuration
|
|
11570
|
+
* @param testFiles - Array of test file paths
|
|
11571
|
+
* @param shardConfig - Shard configuration in format "index/total" (e.g., "1/4")
|
|
11572
|
+
* @returns - Filtered array of test files for this shard
|
|
11573
|
+
*/
|
|
11574
|
+
_applySharding(testFiles: string[], shardConfig: string): string[];
|
|
12206
11575
|
/**
|
|
12207
11576
|
* Run a specific test or all loaded tests.
|
|
12208
11577
|
*/
|
|
@@ -12367,6 +11736,63 @@ declare namespace CodeceptJS {
|
|
|
12367
11736
|
*/
|
|
12368
11737
|
transpose(): void;
|
|
12369
11738
|
}
|
|
11739
|
+
/**
|
|
11740
|
+
* - Designed for use in CodeceptJS tests as a "soft assertion."
|
|
11741
|
+
* Unlike standard assertions, it does not stop the test execution on failure.
|
|
11742
|
+
* - Starts a new recorder session named 'hopeThat' and manages state restoration.
|
|
11743
|
+
* - Logs errors and attaches them as notes to the test, enabling post-test reporting of soft assertion failures.
|
|
11744
|
+
* - Resets the `store.hopeThat` flag after the execution, ensuring clean state for subsequent operations.
|
|
11745
|
+
* @example
|
|
11746
|
+
* const { hopeThat } = require('codeceptjs/effects')
|
|
11747
|
+
* await hopeThat(() => {
|
|
11748
|
+
* I.see('Welcome'); // Perform a soft assertion
|
|
11749
|
+
* });
|
|
11750
|
+
* @param callback - The callback function containing the logic to validate.
|
|
11751
|
+
* This function should perform the desired assertion or condition check.
|
|
11752
|
+
* @returns A promise resolving to `true` if the assertion or condition was successful,
|
|
11753
|
+
* or `false` if an error occurred.
|
|
11754
|
+
*/
|
|
11755
|
+
function hopeThat(callback: (...params: any[]) => any): Promise<boolean | any>;
|
|
11756
|
+
/**
|
|
11757
|
+
* - This function is designed for use in CodeceptJS tests to handle intermittent or flaky test steps.
|
|
11758
|
+
* - Starts a new recorder session for each retry attempt, ensuring proper state management and error handling.
|
|
11759
|
+
* - Logs errors and retries the callback until it either succeeds or the maximum number of attempts is reached.
|
|
11760
|
+
* - Restores the session state after each attempt, whether successful or not.
|
|
11761
|
+
* @example
|
|
11762
|
+
* const { hopeThat } = require('codeceptjs/effects')
|
|
11763
|
+
* await retryTo((tries) => {
|
|
11764
|
+
* if (tries < 3) {
|
|
11765
|
+
* I.see('Non-existent element'); // Simulates a failure
|
|
11766
|
+
* } else {
|
|
11767
|
+
* I.see('Welcome'); // Succeeds on the 3rd attempt
|
|
11768
|
+
* }
|
|
11769
|
+
* }, 5, 300); // Retry up to 5 times, with a 300ms interval
|
|
11770
|
+
* @param callback - The function to execute, which will be retried upon failure.
|
|
11771
|
+
* Receives the current retry count as an argument.
|
|
11772
|
+
* @param maxTries - The maximum number of attempts to retry the callback.
|
|
11773
|
+
* @param [pollInterval = 200] - The delay (in milliseconds) between retry attempts.
|
|
11774
|
+
* @returns A promise that resolves when the callback executes successfully, or rejects after reaching the maximum retries.
|
|
11775
|
+
*/
|
|
11776
|
+
function retryTo(callback: (...params: any[]) => any, maxTries: number, pollInterval?: number): Promise<void | any>;
|
|
11777
|
+
/**
|
|
11778
|
+
* - Useful for scenarios where certain steps are optional or their failure should not interrupt the test flow.
|
|
11779
|
+
* - Starts a new recorder session named 'tryTo' for isolation and error handling.
|
|
11780
|
+
* - Captures errors during execution and logs them for debugging purposes.
|
|
11781
|
+
* - Ensures the `store.tryTo` flag is reset after execution to maintain a clean state.
|
|
11782
|
+
* @example
|
|
11783
|
+
* const { tryTo } = require('codeceptjs/effects')
|
|
11784
|
+
* const wasSuccessful = await tryTo(() => {
|
|
11785
|
+
* I.see('Welcome'); // Attempt to find an element on the page
|
|
11786
|
+
* });
|
|
11787
|
+
*
|
|
11788
|
+
* if (!wasSuccessful) {
|
|
11789
|
+
* I.say('Optional step failed, but test continues.');
|
|
11790
|
+
* }
|
|
11791
|
+
* @param callback - The function to execute, which may succeed or fail.
|
|
11792
|
+
* This function contains the logic to be attempted.
|
|
11793
|
+
* @returns A promise resolving to `true` if the step succeeds, or `false` if it fails.
|
|
11794
|
+
*/
|
|
11795
|
+
function tryTo(callback: (...params: any[]) => any): Promise<boolean | any>;
|
|
12370
11796
|
namespace event {
|
|
12371
11797
|
const dispatcher: NodeJS.EventEmitter;
|
|
12372
11798
|
const test: {
|
|
@@ -12639,6 +12065,10 @@ declare namespace CodeceptJS {
|
|
|
12639
12065
|
* Get a state of current queue and tasks
|
|
12640
12066
|
*/
|
|
12641
12067
|
toString(): string;
|
|
12068
|
+
/**
|
|
12069
|
+
* Get current session ID
|
|
12070
|
+
*/
|
|
12071
|
+
getCurrentSessionId(): string | null;
|
|
12642
12072
|
}
|
|
12643
12073
|
interface RecorderSession {
|
|
12644
12074
|
running: boolean;
|
|
@@ -12752,6 +12182,10 @@ declare namespace CodeceptJS {
|
|
|
12752
12182
|
function Feature(title: string, opts?: {
|
|
12753
12183
|
[key: string]: any;
|
|
12754
12184
|
}): FeatureConfig;
|
|
12185
|
+
/**
|
|
12186
|
+
* Exclusive test suite - runs only this feature.
|
|
12187
|
+
*/
|
|
12188
|
+
const only: CodeceptJS.IFeature;
|
|
12755
12189
|
/**
|
|
12756
12190
|
* Pending test suite.
|
|
12757
12191
|
*/
|