codeceptjs 4.0.0-beta.2 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/codecept.js +84 -81
- package/lib/actor.js +13 -13
- package/lib/ai.js +10 -13
- package/lib/assert/empty.js +20 -21
- package/lib/assert/equal.js +37 -39
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +46 -47
- package/lib/assert/throws.js +13 -11
- package/lib/assert/truth.js +19 -22
- package/lib/assert.js +4 -2
- package/lib/cli.js +57 -49
- package/lib/codecept.js +142 -155
- package/lib/colorUtils.js +3 -3
- package/lib/command/configMigrate.js +58 -52
- package/lib/command/definitions.js +88 -89
- package/lib/command/dryRun.js +71 -68
- package/lib/command/generate.js +197 -188
- package/lib/command/gherkin/init.js +27 -16
- package/lib/command/gherkin/snippets.js +20 -20
- package/lib/command/gherkin/steps.js +8 -8
- package/lib/command/info.js +40 -38
- package/lib/command/init.js +290 -288
- package/lib/command/interactive.js +32 -32
- package/lib/command/list.js +26 -26
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +3 -3
- package/lib/command/run-multiple/run.js +6 -2
- package/lib/command/run-multiple.js +113 -93
- package/lib/command/run-rerun.js +20 -25
- package/lib/command/run-workers.js +64 -66
- package/lib/command/run.js +26 -29
- package/lib/command/utils.js +80 -65
- package/lib/command/workers/runTests.js +10 -10
- package/lib/config.js +10 -9
- package/lib/container.js +40 -48
- package/lib/data/context.js +60 -59
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +29 -29
- package/lib/data/table.js +26 -20
- package/lib/event.js +163 -167
- package/lib/heal.js +13 -17
- package/lib/helper/AI.js +130 -41
- package/lib/helper/ApiDataFactory.js +73 -69
- package/lib/helper/Appium.js +413 -382
- package/lib/helper/ExpectHelper.js +40 -48
- package/lib/helper/FileSystem.js +80 -79
- package/lib/helper/GraphQL.js +44 -43
- package/lib/helper/GraphQLDataFactory.js +50 -50
- package/lib/helper/JSONResponse.js +65 -62
- package/lib/helper/Mochawesome.js +28 -28
- package/lib/helper/MockServer.js +12 -14
- package/lib/helper/Nightmare.js +662 -566
- package/lib/helper/Playwright.js +1361 -1216
- package/lib/helper/Protractor.js +663 -627
- package/lib/helper/Puppeteer.js +1231 -1128
- package/lib/helper/REST.js +159 -68
- package/lib/helper/SoftExpectHelper.js +2 -2
- package/lib/helper/TestCafe.js +490 -484
- package/lib/helper/WebDriver.js +1297 -1156
- package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
- package/lib/helper/errors/ConnectionRefused.js +1 -1
- package/lib/helper/errors/ElementAssertion.js +2 -2
- package/lib/helper/errors/ElementNotFound.js +2 -2
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
- package/lib/helper/extras/Console.js +1 -1
- package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
- package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
- package/lib/helper/extras/PlaywrightRestartOpts.js +21 -18
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +3 -3
- package/lib/helper/network/actions.js +14 -7
- package/lib/helper/network/utils.js +3 -2
- package/lib/helper/scripts/blurElement.js +1 -1
- package/lib/helper/scripts/focusElement.js +1 -1
- package/lib/helper/scripts/highlightElement.js +1 -1
- package/lib/helper/scripts/isElementClickable.js +1 -1
- package/lib/helper/testcafe/testControllerHolder.js +1 -1
- package/lib/helper/testcafe/testcafe-utils.js +6 -7
- package/lib/helper.js +1 -3
- package/lib/history.js +6 -5
- package/lib/hooks.js +6 -6
- package/lib/html.js +7 -7
- package/lib/index.js +25 -41
- package/lib/interfaces/bdd.js +47 -64
- package/lib/interfaces/featureConfig.js +19 -19
- package/lib/interfaces/gherkin.js +124 -118
- package/lib/interfaces/scenarioConfig.js +29 -29
- package/lib/listener/artifacts.js +9 -9
- package/lib/listener/config.js +24 -24
- package/lib/listener/exit.js +12 -12
- package/lib/listener/helpers.js +42 -42
- package/lib/listener/mocha.js +11 -11
- package/lib/listener/retry.js +32 -30
- package/lib/listener/steps.js +50 -53
- package/lib/listener/timeout.js +54 -54
- package/lib/locator.js +6 -10
- package/lib/mochaFactory.js +18 -15
- package/lib/output.js +6 -10
- package/lib/parser.js +15 -12
- package/lib/pause.js +40 -33
- package/lib/plugin/allure.js +15 -15
- package/lib/plugin/autoDelay.js +29 -37
- package/lib/plugin/autoLogin.js +70 -65
- package/lib/plugin/commentStep.js +18 -18
- package/lib/plugin/coverage.js +115 -67
- package/lib/plugin/customLocator.js +21 -20
- package/lib/plugin/debugErrors.js +24 -24
- package/lib/plugin/eachElement.js +38 -38
- package/lib/plugin/fakerTransform.js +6 -6
- package/lib/plugin/heal.js +67 -108
- package/lib/plugin/pauseOnFail.js +11 -11
- package/lib/plugin/retryFailedStep.js +32 -39
- package/lib/plugin/retryTo.js +46 -40
- package/lib/plugin/screenshotOnFail.js +109 -87
- package/lib/plugin/selenoid.js +131 -118
- package/lib/plugin/standardActingHelpers.js +2 -8
- package/lib/plugin/stepByStepReport.js +110 -91
- package/lib/plugin/stepTimeout.js +24 -23
- package/lib/plugin/subtitles.js +34 -35
- package/lib/plugin/tryTo.js +40 -30
- package/lib/plugin/wdio.js +78 -75
- package/lib/recorder.js +14 -17
- package/lib/rerun.js +11 -10
- package/lib/scenario.js +25 -23
- package/lib/secret.js +4 -2
- package/lib/session.js +10 -10
- package/lib/step.js +12 -9
- package/lib/store.js +2 -3
- package/lib/transform.js +1 -1
- package/lib/translation.js +7 -8
- package/lib/ui.js +12 -14
- package/lib/utils.js +70 -72
- package/lib/within.js +10 -10
- package/lib/workerStorage.js +27 -25
- package/lib/workers.js +29 -32
- package/package.json +56 -57
- package/translations/de-DE.js +1 -1
- package/translations/fr-FR.js +1 -1
- package/translations/index.js +9 -13
- package/translations/it-IT.js +1 -1
- package/translations/ja-JP.js +1 -1
- package/translations/pl-PL.js +1 -1
- package/translations/pt-BR.js +1 -1
- package/translations/ru-RU.js +1 -1
- package/translations/zh-CN.js +1 -1
- package/translations/zh-TW.js +1 -1
- package/typings/index.d.ts +415 -65
- package/typings/promiseBasedTypes.d.ts +32 -0
- package/typings/types.d.ts +32 -0
- package/lib/dirname.js +0 -5
- package/lib/helper/Expect.js +0 -425
|
@@ -1184,6 +1184,10 @@ declare namespace CodeceptJS {
|
|
|
1184
1184
|
// @ts-ignore
|
|
1185
1185
|
// @ts-ignore
|
|
1186
1186
|
// @ts-ignore
|
|
1187
|
+
// @ts-ignore
|
|
1188
|
+
// @ts-ignore
|
|
1189
|
+
// @ts-ignore
|
|
1190
|
+
// @ts-ignore
|
|
1187
1191
|
class ExpectHelper {
|
|
1188
1192
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
1189
1193
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
@@ -1299,6 +1303,10 @@ declare namespace CodeceptJS {
|
|
|
1299
1303
|
// @ts-ignore
|
|
1300
1304
|
// @ts-ignore
|
|
1301
1305
|
// @ts-ignore
|
|
1306
|
+
// @ts-ignore
|
|
1307
|
+
// @ts-ignore
|
|
1308
|
+
// @ts-ignore
|
|
1309
|
+
// @ts-ignore
|
|
1302
1310
|
class ExpectHelper {
|
|
1303
1311
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
1304
1312
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
@@ -1974,6 +1982,10 @@ declare namespace CodeceptJS {
|
|
|
1974
1982
|
// @ts-ignore
|
|
1975
1983
|
// @ts-ignore
|
|
1976
1984
|
// @ts-ignore
|
|
1985
|
+
// @ts-ignore
|
|
1986
|
+
// @ts-ignore
|
|
1987
|
+
// @ts-ignore
|
|
1988
|
+
// @ts-ignore
|
|
1977
1989
|
type MockServerConfig = {
|
|
1978
1990
|
port?: number;
|
|
1979
1991
|
host?: string;
|
|
@@ -2102,6 +2114,10 @@ declare namespace CodeceptJS {
|
|
|
2102
2114
|
// @ts-ignore
|
|
2103
2115
|
// @ts-ignore
|
|
2104
2116
|
// @ts-ignore
|
|
2117
|
+
// @ts-ignore
|
|
2118
|
+
// @ts-ignore
|
|
2119
|
+
// @ts-ignore
|
|
2120
|
+
// @ts-ignore
|
|
2105
2121
|
class MockServer {
|
|
2106
2122
|
/**
|
|
2107
2123
|
* Start the mock server
|
|
@@ -3179,6 +3195,10 @@ declare namespace CodeceptJS {
|
|
|
3179
3195
|
// @ts-ignore
|
|
3180
3196
|
// @ts-ignore
|
|
3181
3197
|
// @ts-ignore
|
|
3198
|
+
// @ts-ignore
|
|
3199
|
+
// @ts-ignore
|
|
3200
|
+
// @ts-ignore
|
|
3201
|
+
// @ts-ignore
|
|
3182
3202
|
type PlaywrightConfig = {
|
|
3183
3203
|
url?: string;
|
|
3184
3204
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6559,6 +6579,10 @@ declare namespace CodeceptJS {
|
|
|
6559
6579
|
// @ts-ignore
|
|
6560
6580
|
// @ts-ignore
|
|
6561
6581
|
// @ts-ignore
|
|
6582
|
+
// @ts-ignore
|
|
6583
|
+
// @ts-ignore
|
|
6584
|
+
// @ts-ignore
|
|
6585
|
+
// @ts-ignore
|
|
6562
6586
|
type PuppeteerConfig = {
|
|
6563
6587
|
url: string;
|
|
6564
6588
|
basicAuth?: any;
|
|
@@ -8369,6 +8393,10 @@ declare namespace CodeceptJS {
|
|
|
8369
8393
|
// @ts-ignore
|
|
8370
8394
|
// @ts-ignore
|
|
8371
8395
|
// @ts-ignore
|
|
8396
|
+
// @ts-ignore
|
|
8397
|
+
// @ts-ignore
|
|
8398
|
+
// @ts-ignore
|
|
8399
|
+
// @ts-ignore
|
|
8372
8400
|
type RESTConfig = {
|
|
8373
8401
|
endpoint?: string;
|
|
8374
8402
|
prettyPrintJson?: boolean;
|
|
@@ -9751,6 +9779,10 @@ declare namespace CodeceptJS {
|
|
|
9751
9779
|
// @ts-ignore
|
|
9752
9780
|
// @ts-ignore
|
|
9753
9781
|
// @ts-ignore
|
|
9782
|
+
// @ts-ignore
|
|
9783
|
+
// @ts-ignore
|
|
9784
|
+
// @ts-ignore
|
|
9785
|
+
// @ts-ignore
|
|
9754
9786
|
type WebDriverConfig = {
|
|
9755
9787
|
url: string;
|
|
9756
9788
|
browser: string;
|
package/typings/types.d.ts
CHANGED
|
@@ -1208,6 +1208,10 @@ declare namespace CodeceptJS {
|
|
|
1208
1208
|
// @ts-ignore
|
|
1209
1209
|
// @ts-ignore
|
|
1210
1210
|
// @ts-ignore
|
|
1211
|
+
// @ts-ignore
|
|
1212
|
+
// @ts-ignore
|
|
1213
|
+
// @ts-ignore
|
|
1214
|
+
// @ts-ignore
|
|
1211
1215
|
class ExpectHelper {
|
|
1212
1216
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1213
1217
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
@@ -1323,6 +1327,10 @@ declare namespace CodeceptJS {
|
|
|
1323
1327
|
// @ts-ignore
|
|
1324
1328
|
// @ts-ignore
|
|
1325
1329
|
// @ts-ignore
|
|
1330
|
+
// @ts-ignore
|
|
1331
|
+
// @ts-ignore
|
|
1332
|
+
// @ts-ignore
|
|
1333
|
+
// @ts-ignore
|
|
1326
1334
|
class ExpectHelper {
|
|
1327
1335
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1328
1336
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
@@ -2001,6 +2009,10 @@ declare namespace CodeceptJS {
|
|
|
2001
2009
|
// @ts-ignore
|
|
2002
2010
|
// @ts-ignore
|
|
2003
2011
|
// @ts-ignore
|
|
2012
|
+
// @ts-ignore
|
|
2013
|
+
// @ts-ignore
|
|
2014
|
+
// @ts-ignore
|
|
2015
|
+
// @ts-ignore
|
|
2004
2016
|
type MockServerConfig = {
|
|
2005
2017
|
port?: number;
|
|
2006
2018
|
host?: string;
|
|
@@ -2129,6 +2141,10 @@ declare namespace CodeceptJS {
|
|
|
2129
2141
|
// @ts-ignore
|
|
2130
2142
|
// @ts-ignore
|
|
2131
2143
|
// @ts-ignore
|
|
2144
|
+
// @ts-ignore
|
|
2145
|
+
// @ts-ignore
|
|
2146
|
+
// @ts-ignore
|
|
2147
|
+
// @ts-ignore
|
|
2132
2148
|
class MockServer {
|
|
2133
2149
|
/**
|
|
2134
2150
|
* Start the mock server
|
|
@@ -3272,6 +3288,10 @@ declare namespace CodeceptJS {
|
|
|
3272
3288
|
// @ts-ignore
|
|
3273
3289
|
// @ts-ignore
|
|
3274
3290
|
// @ts-ignore
|
|
3291
|
+
// @ts-ignore
|
|
3292
|
+
// @ts-ignore
|
|
3293
|
+
// @ts-ignore
|
|
3294
|
+
// @ts-ignore
|
|
3275
3295
|
type PlaywrightConfig = {
|
|
3276
3296
|
url?: string;
|
|
3277
3297
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6803,6 +6823,10 @@ declare namespace CodeceptJS {
|
|
|
6803
6823
|
// @ts-ignore
|
|
6804
6824
|
// @ts-ignore
|
|
6805
6825
|
// @ts-ignore
|
|
6826
|
+
// @ts-ignore
|
|
6827
|
+
// @ts-ignore
|
|
6828
|
+
// @ts-ignore
|
|
6829
|
+
// @ts-ignore
|
|
6806
6830
|
type PuppeteerConfig = {
|
|
6807
6831
|
url: string;
|
|
6808
6832
|
basicAuth?: any;
|
|
@@ -8749,6 +8773,10 @@ declare namespace CodeceptJS {
|
|
|
8749
8773
|
// @ts-ignore
|
|
8750
8774
|
// @ts-ignore
|
|
8751
8775
|
// @ts-ignore
|
|
8776
|
+
// @ts-ignore
|
|
8777
|
+
// @ts-ignore
|
|
8778
|
+
// @ts-ignore
|
|
8779
|
+
// @ts-ignore
|
|
8752
8780
|
type RESTConfig = {
|
|
8753
8781
|
endpoint?: string;
|
|
8754
8782
|
prettyPrintJson?: boolean;
|
|
@@ -10191,6 +10219,10 @@ declare namespace CodeceptJS {
|
|
|
10191
10219
|
// @ts-ignore
|
|
10192
10220
|
// @ts-ignore
|
|
10193
10221
|
// @ts-ignore
|
|
10222
|
+
// @ts-ignore
|
|
10223
|
+
// @ts-ignore
|
|
10224
|
+
// @ts-ignore
|
|
10225
|
+
// @ts-ignore
|
|
10194
10226
|
type WebDriverConfig = {
|
|
10195
10227
|
url: string;
|
|
10196
10228
|
browser: string;
|
package/lib/dirname.js
DELETED
package/lib/helper/Expect.js
DELETED
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
import * as chai from 'chai';
|
|
2
|
-
import chai_json_schema from 'chai-json-schema';
|
|
3
|
-
import chai_match_pattern from 'chai-match-pattern';
|
|
4
|
-
import chai_exclude from 'chai-exclude';
|
|
5
|
-
import chai_string from 'chai-string';
|
|
6
|
-
import * as output from '../output.js';
|
|
7
|
-
|
|
8
|
-
chai.use(chai_string);
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
chai.use(chai_exclude);
|
|
11
|
-
chai.use(chai_match_pattern);
|
|
12
|
-
chai.use(chai_json_schema);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* This helper allows performing assertions based on Chai.
|
|
16
|
-
*
|
|
17
|
-
* ### Examples
|
|
18
|
-
*
|
|
19
|
-
* Zero-configuration when paired with other helpers like REST, Playwright:
|
|
20
|
-
*
|
|
21
|
-
* ```js
|
|
22
|
-
* // inside codecept.conf.js
|
|
23
|
-
*{
|
|
24
|
-
* helpers: {
|
|
25
|
-
* Playwright: {...},
|
|
26
|
-
* Expect: {},
|
|
27
|
-
* }
|
|
28
|
-
*}
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* ## Methods
|
|
32
|
-
*/
|
|
33
|
-
class ExpectHelper {
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @param {*} actualValue
|
|
37
|
-
* @param {*} expectedValue
|
|
38
|
-
* @param {*} [customErrorMsg]
|
|
39
|
-
*/
|
|
40
|
-
expectEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`);
|
|
43
|
-
return chai.expect(actualValue, customErrorMsg).to.equal(expectedValue);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {*} actualValue
|
|
49
|
-
* @param {*} expectedValue
|
|
50
|
-
* @param {*} [customErrorMsg]
|
|
51
|
-
*/
|
|
52
|
-
expectNotEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
53
|
-
// @ts-ignore
|
|
54
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to not equal "${JSON.stringify(expectedValue)}"`);
|
|
55
|
-
return chai.expect(actualValue, customErrorMsg).not.to.equal(expectedValue);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* @param {*} actualValue
|
|
61
|
-
* @param {*} expectedValue
|
|
62
|
-
* @param {*} [customErrorMsg]
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
expectDeepEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to deep equal "${JSON.stringify(expectedValue)}"`);
|
|
68
|
-
return chai.expect(actualValue, customErrorMsg).to.deep.equal(expectedValue);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
* @param {*} actualValue
|
|
74
|
-
* @param {*} expectedValue
|
|
75
|
-
* @param {*} [customErrorMsg]
|
|
76
|
-
*/
|
|
77
|
-
expectNotDeepEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to not deep equal "${JSON.stringify(expectedValue)}"`);
|
|
80
|
-
return chai.expect(actualValue, customErrorMsg).to.not.deep.equal(expectedValue);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
* @param {*} actualValue
|
|
86
|
-
* @param {*} expectedValueToContain
|
|
87
|
-
* @param {*} [customErrorMsg]
|
|
88
|
-
*/
|
|
89
|
-
expectContain(actualValue, expectedValueToContain, customErrorMsg = '') {
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to contain "${JSON.stringify(expectedValueToContain)}"`);
|
|
92
|
-
return chai.expect(actualValue, customErrorMsg).to.contain(
|
|
93
|
-
expectedValueToContain,
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* @param {*} actualValue
|
|
100
|
-
* @param {*} expectedValueToNotContain
|
|
101
|
-
* @param {*} [customErrorMsg]
|
|
102
|
-
*/
|
|
103
|
-
expectNotContain(
|
|
104
|
-
actualValue,
|
|
105
|
-
expectedValueToNotContain,
|
|
106
|
-
customErrorMsg = '',
|
|
107
|
-
) {
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to not contain "${JSON.stringify(expectedValueToNotContain)}"`);
|
|
110
|
-
return chai.expect(actualValue, customErrorMsg).not.to.contain(
|
|
111
|
-
expectedValueToNotContain,
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
*
|
|
117
|
-
* @param {*} actualValue
|
|
118
|
-
* @param {*} expectedValueToStartWith
|
|
119
|
-
* @param {*} [customErrorMsg]
|
|
120
|
-
*/
|
|
121
|
-
expectStartsWith(actualValue, expectedValueToStartWith, customErrorMsg = '') {
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to start with "${JSON.stringify(expectedValueToStartWith)}"`);
|
|
124
|
-
return chai.expect(actualValue, customErrorMsg).to.startsWith(
|
|
125
|
-
expectedValueToStartWith,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
*
|
|
131
|
-
* @param {*} actualValue
|
|
132
|
-
* @param {*} expectedValueToNotStartWith
|
|
133
|
-
* @param {*} [customErrorMsg]
|
|
134
|
-
*/
|
|
135
|
-
expectNotStartsWith(
|
|
136
|
-
actualValue,
|
|
137
|
-
expectedValueToNotStartWith,
|
|
138
|
-
customErrorMsg = '',
|
|
139
|
-
) {
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to not start with "${JSON.stringify(expectedValueToNotStartWith)}"`);
|
|
142
|
-
return chai.expect(actualValue, customErrorMsg).not.to.startsWith(
|
|
143
|
-
expectedValueToNotStartWith,
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @param {*} actualValue
|
|
149
|
-
* @param {*} expectedValueToEndWith
|
|
150
|
-
* @param {*} [customErrorMsg]
|
|
151
|
-
*/
|
|
152
|
-
expectEndsWith(actualValue, expectedValueToEndWith, customErrorMsg = '') {
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to end with "${JSON.stringify(expectedValueToEndWith)}"`);
|
|
155
|
-
return chai.expect(actualValue, customErrorMsg).to.endsWith(
|
|
156
|
-
expectedValueToEndWith,
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @param {*} actualValue
|
|
162
|
-
* @param {*} expectedValueToNotEndWith
|
|
163
|
-
* @param {*} [customErrorMsg]
|
|
164
|
-
*/
|
|
165
|
-
expectNotEndsWith(
|
|
166
|
-
actualValue,
|
|
167
|
-
expectedValueToNotEndWith,
|
|
168
|
-
customErrorMsg = '',
|
|
169
|
-
) {
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to not end with "${JSON.stringify(expectedValueToNotEndWith)}"`);
|
|
172
|
-
return chai.expect(actualValue, customErrorMsg).not.to.endsWith(
|
|
173
|
-
expectedValueToNotEndWith,
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @param {*} targetData
|
|
179
|
-
* @param {*} jsonSchema
|
|
180
|
-
* @param {*} [customErrorMsg]
|
|
181
|
-
*/
|
|
182
|
-
expectJsonSchema(targetData, jsonSchema, customErrorMsg = '') {
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to match this JSON schema "${JSON.stringify(jsonSchema)}"`);
|
|
185
|
-
|
|
186
|
-
return chai.expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* @param {*} targetData
|
|
191
|
-
* @param {*} jsonSchema
|
|
192
|
-
* @param {*} [customErrorMsg]
|
|
193
|
-
* @param {*} [ajvOptions] Pass AJV options
|
|
194
|
-
*/
|
|
195
|
-
expectJsonSchemaUsingAJV(
|
|
196
|
-
targetData,
|
|
197
|
-
jsonSchema,
|
|
198
|
-
customErrorMsg = '',
|
|
199
|
-
ajvOptions = { allErrors: true },
|
|
200
|
-
) {
|
|
201
|
-
// @ts-ignore
|
|
202
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to match this JSON schema using AJV "${JSON.stringify(jsonSchema)}"`);
|
|
203
|
-
chai.use(require('chai-json-schema-ajv').create(ajvOptions));
|
|
204
|
-
return chai.expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* @param {*} targetData
|
|
209
|
-
* @param {*} propertyName
|
|
210
|
-
* @param {*} [customErrorMsg]
|
|
211
|
-
*/
|
|
212
|
-
expectHasProperty(targetData, propertyName, customErrorMsg = '') {
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to have property: "${JSON.stringify(propertyName)}"`);
|
|
215
|
-
return chai.expect(targetData, customErrorMsg).to.have.property(propertyName);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* @param {*} targetData
|
|
220
|
-
* @param {*} propertyName
|
|
221
|
-
* @param {*} [customErrorMsg]
|
|
222
|
-
*/
|
|
223
|
-
expectHasAProperty(targetData, propertyName, customErrorMsg = '') {
|
|
224
|
-
// @ts-ignore
|
|
225
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to have a property: "${JSON.stringify(propertyName)}"`);
|
|
226
|
-
return chai.expect(targetData, customErrorMsg).to.have.a.property(propertyName);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* @param {*} targetData
|
|
231
|
-
* @param {*} type
|
|
232
|
-
* @param {*} [customErrorMsg]
|
|
233
|
-
*/
|
|
234
|
-
expectToBeA(targetData, type, customErrorMsg = '') {
|
|
235
|
-
// @ts-ignore
|
|
236
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to be a "${JSON.stringify(type)}"`);
|
|
237
|
-
return chai.expect(targetData, customErrorMsg).to.be.a(type);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* @param {*} targetData
|
|
242
|
-
* @param {*} type
|
|
243
|
-
* @param {*} [customErrorMsg]
|
|
244
|
-
*/
|
|
245
|
-
expectToBeAn(targetData, type, customErrorMsg = '') {
|
|
246
|
-
// @ts-ignore
|
|
247
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to be an "${JSON.stringify(type)}"`);
|
|
248
|
-
return chai.expect(targetData, customErrorMsg).to.be.an(type);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* @param {*} targetData
|
|
253
|
-
* @param {*} regex
|
|
254
|
-
* @param {*} [customErrorMsg]
|
|
255
|
-
*/
|
|
256
|
-
expectMatchRegex(targetData, regex, customErrorMsg = '') {
|
|
257
|
-
// @ts-ignore
|
|
258
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to match the regex "${JSON.stringify(regex)}"`);
|
|
259
|
-
return chai.expect(targetData, customErrorMsg).to.match(regex);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* @param {*} targetData
|
|
264
|
-
* @param {*} length
|
|
265
|
-
* @param {*} [customErrorMsg]
|
|
266
|
-
*/
|
|
267
|
-
expectLengthOf(targetData, length, customErrorMsg = '') {
|
|
268
|
-
// @ts-ignore
|
|
269
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to have length of "${JSON.stringify(length)}"`);
|
|
270
|
-
return chai.expect(targetData, customErrorMsg).to.have.lengthOf(length);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* @param {*} targetData
|
|
275
|
-
* @param {*} [customErrorMsg]
|
|
276
|
-
*/
|
|
277
|
-
expectEmpty(targetData, customErrorMsg = '') {
|
|
278
|
-
// @ts-ignore
|
|
279
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to be empty`);
|
|
280
|
-
return chai.expect(targetData, customErrorMsg).to.be.empty;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* @param {*} targetData
|
|
285
|
-
* @param {*} [customErrorMsg]
|
|
286
|
-
*/
|
|
287
|
-
expectTrue(targetData, customErrorMsg = '') {
|
|
288
|
-
// @ts-ignore
|
|
289
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to be true`);
|
|
290
|
-
return chai.expect(targetData, customErrorMsg).to.be.true;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* @param {*} targetData
|
|
295
|
-
* @param {*} [customErrorMsg]
|
|
296
|
-
*/
|
|
297
|
-
expectFalse(targetData, customErrorMsg = '') {
|
|
298
|
-
// @ts-ignore
|
|
299
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to be false`);
|
|
300
|
-
return chai.expect(targetData, customErrorMsg).to.be.false;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* @param {*} targetData
|
|
305
|
-
* @param {*} aboveThan
|
|
306
|
-
* @param {*} [customErrorMsg]
|
|
307
|
-
*/
|
|
308
|
-
expectAbove(targetData, aboveThan, customErrorMsg = '') {
|
|
309
|
-
// @ts-ignore
|
|
310
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to be above ${JSON.stringify(aboveThan)}`);
|
|
311
|
-
return chai.expect(targetData, customErrorMsg).to.be.above(aboveThan);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* @param {*} targetData
|
|
316
|
-
* @param {*} belowThan
|
|
317
|
-
* @param {*} [customErrorMsg]
|
|
318
|
-
*/
|
|
319
|
-
expectBelow(targetData, belowThan, customErrorMsg = '') {
|
|
320
|
-
// @ts-ignore
|
|
321
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to be below ${JSON.stringify(belowThan)}`);
|
|
322
|
-
return chai.expect(targetData, customErrorMsg).to.be.below(belowThan);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* @param {*} targetData
|
|
327
|
-
* @param {*} lengthAboveThan
|
|
328
|
-
* @param {*} [customErrorMsg]
|
|
329
|
-
*/
|
|
330
|
-
expectLengthAboveThan(targetData, lengthAboveThan, customErrorMsg = '') {
|
|
331
|
-
// @ts-ignore
|
|
332
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to have length of above ${JSON.stringify(lengthAboveThan)}`);
|
|
333
|
-
return chai.expect(targetData, customErrorMsg).to.have.lengthOf.above(
|
|
334
|
-
lengthAboveThan,
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* @param {*} targetData
|
|
340
|
-
* @param {*} lengthBelowThan
|
|
341
|
-
* @param {*} [customErrorMsg]
|
|
342
|
-
*/
|
|
343
|
-
expectLengthBelowThan(targetData, lengthBelowThan, customErrorMsg = '') {
|
|
344
|
-
// @ts-ignore
|
|
345
|
-
output.output.step(`I expect "${JSON.stringify(targetData)}" to have length of below ${JSON.stringify(lengthBelowThan)}`);
|
|
346
|
-
return chai.expect(targetData, customErrorMsg).to.have.lengthOf.below(
|
|
347
|
-
lengthBelowThan,
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* @param {*} actualValue
|
|
353
|
-
* @param {*} expectedValue
|
|
354
|
-
* @param {*} [customErrorMsg]
|
|
355
|
-
*/
|
|
356
|
-
expectEqualIgnoreCase(actualValue, expectedValue, customErrorMsg = '') {
|
|
357
|
-
// @ts-ignore
|
|
358
|
-
output.output.step(`I expect and ingore case "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`);
|
|
359
|
-
return chai.expect(actualValue, customErrorMsg).to.equalIgnoreCase(
|
|
360
|
-
expectedValue,
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* expects members of two arrays are deeply equal
|
|
366
|
-
* @param {*} actualValue
|
|
367
|
-
* @param {*} expectedValue
|
|
368
|
-
* @param {*} [customErrorMsg]
|
|
369
|
-
*/
|
|
370
|
-
expectDeepMembers(actualValue, expectedValue, customErrorMsg = '') {
|
|
371
|
-
// @ts-ignore
|
|
372
|
-
output.output.step(`I expect members of "${JSON.stringify(actualValue)}" and "${JSON.stringify(expectedValue)}" arrays are deeply equal`);
|
|
373
|
-
return chai.expect(actualValue, customErrorMsg).to.have.deep.members(
|
|
374
|
-
expectedValue,
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* expects an array to be a superset of another array
|
|
380
|
-
* @param {*} superset
|
|
381
|
-
* @param {*} set
|
|
382
|
-
* @param {*} [customErrorMsg]
|
|
383
|
-
*/
|
|
384
|
-
expectDeepIncludeMembers(superset, set, customErrorMsg = '') {
|
|
385
|
-
// @ts-ignore
|
|
386
|
-
output.output.step(`I expect "${JSON.stringify(superset)}" array to be a superset of "${JSON.stringify(set)}" array`);
|
|
387
|
-
return chai.expect(superset, customErrorMsg).to.deep.include.members(
|
|
388
|
-
set,
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* expects members of two JSON objects are deeply equal excluding some properties
|
|
394
|
-
* @param {*} actualValue
|
|
395
|
-
* @param {*} expectedValue
|
|
396
|
-
* @param {*} fieldsToExclude
|
|
397
|
-
* @param {*} [customErrorMsg]
|
|
398
|
-
*/
|
|
399
|
-
expectDeepEqualExcluding(
|
|
400
|
-
actualValue,
|
|
401
|
-
expectedValue,
|
|
402
|
-
fieldsToExclude,
|
|
403
|
-
customErrorMsg = '',
|
|
404
|
-
) {
|
|
405
|
-
// @ts-ignore
|
|
406
|
-
output.output.step(`I expect members of "${JSON.stringify(actualValue)}" and "${JSON.stringify(expectedValue)}" JSON objects are deeply equal excluding properties: ${JSON.stringify(fieldsToExclude)}`);
|
|
407
|
-
return chai.expect(actualValue, customErrorMsg)
|
|
408
|
-
.excludingEvery(fieldsToExclude)
|
|
409
|
-
.to.deep.equal(expectedValue);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* expects a JSON object matches a provided pattern
|
|
414
|
-
* @param {*} actualValue
|
|
415
|
-
* @param {*} expectedPattern
|
|
416
|
-
* @param {*} [customErrorMsg]
|
|
417
|
-
*/
|
|
418
|
-
expectMatchesPattern(actualValue, expectedPattern, customErrorMsg = '') {
|
|
419
|
-
// @ts-ignore
|
|
420
|
-
output.output.step(`I expect "${JSON.stringify(actualValue)}" to match the ${JSON.stringify(expectedPattern)} pattern`);
|
|
421
|
-
return chai.expect(actualValue, customErrorMsg).to.matchPattern(expectedPattern);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
export default ExpectHelper;
|