codeceptjs 3.6.4 → 3.6.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/bin/codecept.js +84 -63
- package/lib/assert/empty.js +19 -19
- package/lib/assert/equal.js +32 -30
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +42 -42
- package/lib/assert/throws.js +13 -11
- package/lib/assert/truth.js +17 -18
- package/lib/command/configMigrate.js +57 -52
- package/lib/command/definitions.js +88 -88
- package/lib/command/dryRun.js +65 -63
- package/lib/command/generate.js +191 -181
- package/lib/command/info.js +39 -37
- package/lib/command/init.js +289 -286
- package/lib/command/interactive.js +32 -32
- package/lib/command/list.js +26 -26
- package/lib/command/run-multiple.js +113 -93
- package/lib/command/run-rerun.js +22 -22
- package/lib/command/run-workers.js +63 -63
- package/lib/command/run.js +24 -26
- package/lib/command/utils.js +64 -63
- package/lib/data/context.js +60 -60
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +29 -29
- package/lib/data/table.js +26 -20
- package/lib/helper/AI.js +67 -65
- package/lib/helper/ApiDataFactory.js +72 -69
- package/lib/helper/Appium.js +409 -379
- package/lib/helper/ExpectHelper.js +214 -248
- package/lib/helper/FileSystem.js +77 -78
- package/lib/helper/GraphQL.js +44 -43
- package/lib/helper/GraphQLDataFactory.js +49 -50
- package/lib/helper/JSONResponse.js +64 -62
- package/lib/helper/Mochawesome.js +28 -28
- package/lib/helper/MockServer.js +12 -12
- package/lib/helper/Nightmare.js +664 -572
- package/lib/helper/Playwright.js +1320 -1211
- package/lib/helper/Protractor.js +663 -629
- package/lib/helper/Puppeteer.js +1232 -1124
- package/lib/helper/REST.js +87 -72
- package/lib/helper/TestCafe.js +490 -491
- package/lib/helper/WebDriver.js +1294 -1156
- package/lib/interfaces/bdd.js +38 -51
- package/lib/interfaces/featureConfig.js +19 -19
- package/lib/interfaces/gherkin.js +122 -111
- package/lib/interfaces/scenarioConfig.js +29 -29
- package/lib/listener/artifacts.js +9 -9
- package/lib/listener/config.js +24 -23
- 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 -51
- package/lib/listener/timeout.js +53 -53
- package/lib/plugin/allure.js +14 -14
- package/lib/plugin/autoDelay.js +29 -36
- package/lib/plugin/autoLogin.js +70 -66
- package/lib/plugin/commentStep.js +18 -18
- package/lib/plugin/coverage.js +92 -77
- package/lib/plugin/customLocator.js +20 -19
- package/lib/plugin/debugErrors.js +24 -24
- package/lib/plugin/eachElement.js +37 -37
- package/lib/plugin/fakerTransform.js +6 -6
- package/lib/plugin/heal.js +66 -63
- package/lib/plugin/pauseOnFail.js +10 -10
- package/lib/plugin/retryFailedStep.js +31 -38
- package/lib/plugin/retryTo.js +28 -28
- package/lib/plugin/screenshotOnFail.js +107 -86
- package/lib/plugin/selenoid.js +131 -117
- package/lib/plugin/standardActingHelpers.js +2 -8
- package/lib/plugin/stepByStepReport.js +102 -92
- package/lib/plugin/stepTimeout.js +23 -22
- package/lib/plugin/subtitles.js +34 -34
- package/lib/plugin/tryTo.js +39 -29
- package/lib/plugin/wdio.js +77 -72
- package/lib/template/heal.js +11 -14
- package/package.json +4 -2
- package/translations/de-DE.js +1 -1
- package/translations/fr-FR.js +1 -1
- package/translations/index.js +9 -9
- 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/promiseBasedTypes.d.ts +238 -0
- package/typings/types.d.ts +32 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const output = require('../output')
|
|
1
|
+
const output = require('../output')
|
|
2
2
|
|
|
3
|
-
let expect
|
|
3
|
+
let expect
|
|
4
4
|
|
|
5
|
-
import('chai').then(chai => {
|
|
6
|
-
expect = chai.expect
|
|
7
|
-
chai.use(require('chai-string'))
|
|
5
|
+
import('chai').then((chai) => {
|
|
6
|
+
expect = chai.expect
|
|
7
|
+
chai.use(require('chai-string'))
|
|
8
8
|
// @ts-ignore
|
|
9
|
-
chai.use(require('chai-exclude'))
|
|
10
|
-
chai.use(require('chai-match-pattern'))
|
|
11
|
-
chai.use(require('chai-json-schema'))
|
|
12
|
-
})
|
|
9
|
+
chai.use(require('chai-exclude'))
|
|
10
|
+
chai.use(require('chai-match-pattern'))
|
|
11
|
+
chai.use(require('chai-json-schema'))
|
|
12
|
+
})
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* This helper allows performing assertions based on Chai.
|
|
@@ -32,27 +32,27 @@ import('chai').then(chai => {
|
|
|
32
32
|
*/
|
|
33
33
|
class ExpectHelper {
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
*
|
|
36
|
+
* @param {*} actualValue
|
|
37
|
+
* @param {*} expectedValue
|
|
38
|
+
* @param {*} [customErrorMsg]
|
|
39
|
+
*/
|
|
40
40
|
expectEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
41
41
|
// @ts-ignore
|
|
42
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`)
|
|
43
|
-
return expect(actualValue, customErrorMsg).to.equal(expectedValue)
|
|
42
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`)
|
|
43
|
+
return expect(actualValue, customErrorMsg).to.equal(expectedValue)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
*
|
|
48
|
+
* @param {*} actualValue
|
|
49
|
+
* @param {*} expectedValue
|
|
50
|
+
* @param {*} [customErrorMsg]
|
|
51
|
+
*/
|
|
52
52
|
expectNotEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
53
53
|
// @ts-ignore
|
|
54
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to not equal "${JSON.stringify(expectedValue)}"`)
|
|
55
|
-
return expect(actualValue, customErrorMsg).not.to.equal(expectedValue)
|
|
54
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to not equal "${JSON.stringify(expectedValue)}"`)
|
|
55
|
+
return expect(actualValue, customErrorMsg).not.to.equal(expectedValue)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -64,362 +64,328 @@ class ExpectHelper {
|
|
|
64
64
|
*/
|
|
65
65
|
expectDeepEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
66
66
|
// @ts-ignore
|
|
67
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to deep equal "${JSON.stringify(expectedValue)}"`)
|
|
68
|
-
return expect(actualValue, customErrorMsg).to.deep.equal(expectedValue)
|
|
67
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to deep equal "${JSON.stringify(expectedValue)}"`)
|
|
68
|
+
return expect(actualValue, customErrorMsg).to.deep.equal(expectedValue)
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
*
|
|
73
|
+
* @param {*} actualValue
|
|
74
|
+
* @param {*} expectedValue
|
|
75
|
+
* @param {*} [customErrorMsg]
|
|
76
|
+
*/
|
|
77
77
|
expectNotDeepEqual(actualValue, expectedValue, customErrorMsg = '') {
|
|
78
78
|
// @ts-ignore
|
|
79
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to not deep equal "${JSON.stringify(expectedValue)}"`)
|
|
80
|
-
return expect(actualValue, customErrorMsg).to.not.deep.equal(expectedValue)
|
|
79
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to not deep equal "${JSON.stringify(expectedValue)}"`)
|
|
80
|
+
return expect(actualValue, customErrorMsg).to.not.deep.equal(expectedValue)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
*
|
|
85
|
+
* @param {*} actualValue
|
|
86
|
+
* @param {*} expectedValueToContain
|
|
87
|
+
* @param {*} [customErrorMsg]
|
|
88
|
+
*/
|
|
89
89
|
expectContain(actualValue, expectedValueToContain, customErrorMsg = '') {
|
|
90
90
|
// @ts-ignore
|
|
91
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to contain "${JSON.stringify(expectedValueToContain)}"`)
|
|
92
|
-
return expect(actualValue, customErrorMsg).to.contain(
|
|
93
|
-
expectedValueToContain,
|
|
94
|
-
);
|
|
91
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to contain "${JSON.stringify(expectedValueToContain)}"`)
|
|
92
|
+
return expect(actualValue, customErrorMsg).to.contain(expectedValueToContain)
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
expectNotContain(
|
|
104
|
-
actualValue,
|
|
105
|
-
expectedValueToNotContain,
|
|
106
|
-
customErrorMsg = '',
|
|
107
|
-
) {
|
|
96
|
+
*
|
|
97
|
+
* @param {*} actualValue
|
|
98
|
+
* @param {*} expectedValueToNotContain
|
|
99
|
+
* @param {*} [customErrorMsg]
|
|
100
|
+
*/
|
|
101
|
+
expectNotContain(actualValue, expectedValueToNotContain, customErrorMsg = '') {
|
|
108
102
|
// @ts-ignore
|
|
109
|
-
output.step(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
)
|
|
103
|
+
output.step(
|
|
104
|
+
`I expect "${JSON.stringify(actualValue)}" to not contain "${JSON.stringify(expectedValueToNotContain)}"`,
|
|
105
|
+
)
|
|
106
|
+
return expect(actualValue, customErrorMsg).not.to.contain(expectedValueToNotContain)
|
|
113
107
|
}
|
|
114
108
|
|
|
115
109
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
110
|
+
*
|
|
111
|
+
* @param {*} actualValue
|
|
112
|
+
* @param {*} expectedValueToStartWith
|
|
113
|
+
* @param {*} [customErrorMsg]
|
|
114
|
+
*/
|
|
121
115
|
expectStartsWith(actualValue, expectedValueToStartWith, customErrorMsg = '') {
|
|
122
116
|
// @ts-ignore
|
|
123
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to start with "${JSON.stringify(expectedValueToStartWith)}"`)
|
|
124
|
-
return expect(actualValue, customErrorMsg).to.startsWith(
|
|
125
|
-
expectedValueToStartWith,
|
|
126
|
-
);
|
|
117
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to start with "${JSON.stringify(expectedValueToStartWith)}"`)
|
|
118
|
+
return expect(actualValue, customErrorMsg).to.startsWith(expectedValueToStartWith)
|
|
127
119
|
}
|
|
128
120
|
|
|
129
121
|
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
expectNotStartsWith(
|
|
136
|
-
actualValue,
|
|
137
|
-
expectedValueToNotStartWith,
|
|
138
|
-
customErrorMsg = '',
|
|
139
|
-
) {
|
|
122
|
+
*
|
|
123
|
+
* @param {*} actualValue
|
|
124
|
+
* @param {*} expectedValueToNotStartWith
|
|
125
|
+
* @param {*} [customErrorMsg]
|
|
126
|
+
*/
|
|
127
|
+
expectNotStartsWith(actualValue, expectedValueToNotStartWith, customErrorMsg = '') {
|
|
140
128
|
// @ts-ignore
|
|
141
|
-
output.step(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
)
|
|
129
|
+
output.step(
|
|
130
|
+
`I expect "${JSON.stringify(actualValue)}" to not start with "${JSON.stringify(expectedValueToNotStartWith)}"`,
|
|
131
|
+
)
|
|
132
|
+
return expect(actualValue, customErrorMsg).not.to.startsWith(expectedValueToNotStartWith)
|
|
145
133
|
}
|
|
146
134
|
|
|
147
135
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
* @param {*} actualValue
|
|
137
|
+
* @param {*} expectedValueToEndWith
|
|
138
|
+
* @param {*} [customErrorMsg]
|
|
139
|
+
*/
|
|
152
140
|
expectEndsWith(actualValue, expectedValueToEndWith, customErrorMsg = '') {
|
|
153
141
|
// @ts-ignore
|
|
154
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to end with "${JSON.stringify(expectedValueToEndWith)}"`)
|
|
155
|
-
return expect(actualValue, customErrorMsg).to.endsWith(
|
|
156
|
-
expectedValueToEndWith,
|
|
157
|
-
);
|
|
142
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to end with "${JSON.stringify(expectedValueToEndWith)}"`)
|
|
143
|
+
return expect(actualValue, customErrorMsg).to.endsWith(expectedValueToEndWith)
|
|
158
144
|
}
|
|
159
145
|
|
|
160
146
|
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
expectNotEndsWith(
|
|
166
|
-
actualValue,
|
|
167
|
-
expectedValueToNotEndWith,
|
|
168
|
-
customErrorMsg = '',
|
|
169
|
-
) {
|
|
147
|
+
* @param {*} actualValue
|
|
148
|
+
* @param {*} expectedValueToNotEndWith
|
|
149
|
+
* @param {*} [customErrorMsg]
|
|
150
|
+
*/
|
|
151
|
+
expectNotEndsWith(actualValue, expectedValueToNotEndWith, customErrorMsg = '') {
|
|
170
152
|
// @ts-ignore
|
|
171
|
-
output.step(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
)
|
|
153
|
+
output.step(
|
|
154
|
+
`I expect "${JSON.stringify(actualValue)}" to not end with "${JSON.stringify(expectedValueToNotEndWith)}"`,
|
|
155
|
+
)
|
|
156
|
+
return expect(actualValue, customErrorMsg).not.to.endsWith(expectedValueToNotEndWith)
|
|
175
157
|
}
|
|
176
158
|
|
|
177
159
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
160
|
+
* @param {*} targetData
|
|
161
|
+
* @param {*} jsonSchema
|
|
162
|
+
* @param {*} [customErrorMsg]
|
|
163
|
+
*/
|
|
182
164
|
expectJsonSchema(targetData, jsonSchema, customErrorMsg = '') {
|
|
183
165
|
// @ts-ignore
|
|
184
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to match this JSON schema "${JSON.stringify(jsonSchema)}"`)
|
|
166
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to match this JSON schema "${JSON.stringify(jsonSchema)}"`)
|
|
185
167
|
|
|
186
|
-
return expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema)
|
|
168
|
+
return expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema)
|
|
187
169
|
}
|
|
188
170
|
|
|
189
171
|
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
expectJsonSchemaUsingAJV(
|
|
196
|
-
targetData,
|
|
197
|
-
jsonSchema,
|
|
198
|
-
customErrorMsg = '',
|
|
199
|
-
ajvOptions = { allErrors: true },
|
|
200
|
-
) {
|
|
172
|
+
* @param {*} targetData
|
|
173
|
+
* @param {*} jsonSchema
|
|
174
|
+
* @param {*} [customErrorMsg]
|
|
175
|
+
* @param {*} [ajvOptions] Pass AJV options
|
|
176
|
+
*/
|
|
177
|
+
expectJsonSchemaUsingAJV(targetData, jsonSchema, customErrorMsg = '', ajvOptions = { allErrors: true }) {
|
|
201
178
|
// @ts-ignore
|
|
202
|
-
output.step(
|
|
203
|
-
|
|
204
|
-
|
|
179
|
+
output.step(
|
|
180
|
+
`I expect "${JSON.stringify(targetData)}" to match this JSON schema using AJV "${JSON.stringify(jsonSchema)}"`,
|
|
181
|
+
)
|
|
182
|
+
chai.use(require('chai-json-schema-ajv').create(ajvOptions))
|
|
183
|
+
return expect(targetData, customErrorMsg).to.be.jsonSchema(jsonSchema)
|
|
205
184
|
}
|
|
206
185
|
|
|
207
186
|
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
187
|
+
* @param {*} targetData
|
|
188
|
+
* @param {*} propertyName
|
|
189
|
+
* @param {*} [customErrorMsg]
|
|
190
|
+
*/
|
|
212
191
|
expectHasProperty(targetData, propertyName, customErrorMsg = '') {
|
|
213
192
|
// @ts-ignore
|
|
214
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to have property: "${JSON.stringify(propertyName)}"`)
|
|
215
|
-
return expect(targetData, customErrorMsg).to.have.property(propertyName)
|
|
193
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to have property: "${JSON.stringify(propertyName)}"`)
|
|
194
|
+
return expect(targetData, customErrorMsg).to.have.property(propertyName)
|
|
216
195
|
}
|
|
217
196
|
|
|
218
197
|
/**
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
198
|
+
* @param {*} targetData
|
|
199
|
+
* @param {*} propertyName
|
|
200
|
+
* @param {*} [customErrorMsg]
|
|
201
|
+
*/
|
|
223
202
|
expectHasAProperty(targetData, propertyName, customErrorMsg = '') {
|
|
224
203
|
// @ts-ignore
|
|
225
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to have a property: "${JSON.stringify(propertyName)}"`)
|
|
226
|
-
return expect(targetData, customErrorMsg).to.have.a.property(propertyName)
|
|
204
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to have a property: "${JSON.stringify(propertyName)}"`)
|
|
205
|
+
return expect(targetData, customErrorMsg).to.have.a.property(propertyName)
|
|
227
206
|
}
|
|
228
207
|
|
|
229
208
|
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
209
|
+
* @param {*} targetData
|
|
210
|
+
* @param {*} type
|
|
211
|
+
* @param {*} [customErrorMsg]
|
|
212
|
+
*/
|
|
234
213
|
expectToBeA(targetData, type, customErrorMsg = '') {
|
|
235
214
|
// @ts-ignore
|
|
236
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to be a "${JSON.stringify(type)}"`)
|
|
237
|
-
return expect(targetData, customErrorMsg).to.be.a(type)
|
|
215
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to be a "${JSON.stringify(type)}"`)
|
|
216
|
+
return expect(targetData, customErrorMsg).to.be.a(type)
|
|
238
217
|
}
|
|
239
218
|
|
|
240
219
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
220
|
+
* @param {*} targetData
|
|
221
|
+
* @param {*} type
|
|
222
|
+
* @param {*} [customErrorMsg]
|
|
223
|
+
*/
|
|
245
224
|
expectToBeAn(targetData, type, customErrorMsg = '') {
|
|
246
225
|
// @ts-ignore
|
|
247
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to be an "${JSON.stringify(type)}"`)
|
|
248
|
-
return expect(targetData, customErrorMsg).to.be.an(type)
|
|
226
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to be an "${JSON.stringify(type)}"`)
|
|
227
|
+
return expect(targetData, customErrorMsg).to.be.an(type)
|
|
249
228
|
}
|
|
250
229
|
|
|
251
230
|
/**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
231
|
+
* @param {*} targetData
|
|
232
|
+
* @param {*} regex
|
|
233
|
+
* @param {*} [customErrorMsg]
|
|
234
|
+
*/
|
|
256
235
|
expectMatchRegex(targetData, regex, customErrorMsg = '') {
|
|
257
236
|
// @ts-ignore
|
|
258
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to match the regex "${JSON.stringify(regex)}"`)
|
|
259
|
-
return expect(targetData, customErrorMsg).to.match(regex)
|
|
237
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to match the regex "${JSON.stringify(regex)}"`)
|
|
238
|
+
return expect(targetData, customErrorMsg).to.match(regex)
|
|
260
239
|
}
|
|
261
240
|
|
|
262
241
|
/**
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
242
|
+
* @param {*} targetData
|
|
243
|
+
* @param {*} length
|
|
244
|
+
* @param {*} [customErrorMsg]
|
|
245
|
+
*/
|
|
267
246
|
expectLengthOf(targetData, length, customErrorMsg = '') {
|
|
268
247
|
// @ts-ignore
|
|
269
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to have length of "${JSON.stringify(length)}"`)
|
|
270
|
-
return expect(targetData, customErrorMsg).to.have.lengthOf(length)
|
|
248
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to have length of "${JSON.stringify(length)}"`)
|
|
249
|
+
return expect(targetData, customErrorMsg).to.have.lengthOf(length)
|
|
271
250
|
}
|
|
272
251
|
|
|
273
252
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
253
|
+
* @param {*} targetData
|
|
254
|
+
* @param {*} [customErrorMsg]
|
|
255
|
+
*/
|
|
277
256
|
expectEmpty(targetData, customErrorMsg = '') {
|
|
278
257
|
// @ts-ignore
|
|
279
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to be empty`)
|
|
280
|
-
return expect(targetData, customErrorMsg).to.be.empty
|
|
258
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to be empty`)
|
|
259
|
+
return expect(targetData, customErrorMsg).to.be.empty
|
|
281
260
|
}
|
|
282
261
|
|
|
283
262
|
/**
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
263
|
+
* @param {*} targetData
|
|
264
|
+
* @param {*} [customErrorMsg]
|
|
265
|
+
*/
|
|
287
266
|
expectTrue(targetData, customErrorMsg = '') {
|
|
288
267
|
// @ts-ignore
|
|
289
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to be true`)
|
|
290
|
-
return expect(targetData, customErrorMsg).to.be.true
|
|
268
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to be true`)
|
|
269
|
+
return expect(targetData, customErrorMsg).to.be.true
|
|
291
270
|
}
|
|
292
271
|
|
|
293
272
|
/**
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
273
|
+
* @param {*} targetData
|
|
274
|
+
* @param {*} [customErrorMsg]
|
|
275
|
+
*/
|
|
297
276
|
expectFalse(targetData, customErrorMsg = '') {
|
|
298
277
|
// @ts-ignore
|
|
299
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to be false`)
|
|
300
|
-
return expect(targetData, customErrorMsg).to.be.false
|
|
278
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to be false`)
|
|
279
|
+
return expect(targetData, customErrorMsg).to.be.false
|
|
301
280
|
}
|
|
302
281
|
|
|
303
282
|
/**
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
283
|
+
* @param {*} targetData
|
|
284
|
+
* @param {*} aboveThan
|
|
285
|
+
* @param {*} [customErrorMsg]
|
|
286
|
+
*/
|
|
308
287
|
expectAbove(targetData, aboveThan, customErrorMsg = '') {
|
|
309
288
|
// @ts-ignore
|
|
310
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to be above ${JSON.stringify(aboveThan)}`)
|
|
311
|
-
return expect(targetData, customErrorMsg).to.be.above(aboveThan)
|
|
289
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to be above ${JSON.stringify(aboveThan)}`)
|
|
290
|
+
return expect(targetData, customErrorMsg).to.be.above(aboveThan)
|
|
312
291
|
}
|
|
313
292
|
|
|
314
293
|
/**
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
294
|
+
* @param {*} targetData
|
|
295
|
+
* @param {*} belowThan
|
|
296
|
+
* @param {*} [customErrorMsg]
|
|
297
|
+
*/
|
|
319
298
|
expectBelow(targetData, belowThan, customErrorMsg = '') {
|
|
320
299
|
// @ts-ignore
|
|
321
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to be below ${JSON.stringify(belowThan)}`)
|
|
322
|
-
return expect(targetData, customErrorMsg).to.be.below(belowThan)
|
|
300
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to be below ${JSON.stringify(belowThan)}`)
|
|
301
|
+
return expect(targetData, customErrorMsg).to.be.below(belowThan)
|
|
323
302
|
}
|
|
324
303
|
|
|
325
304
|
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
305
|
+
* @param {*} targetData
|
|
306
|
+
* @param {*} lengthAboveThan
|
|
307
|
+
* @param {*} [customErrorMsg]
|
|
308
|
+
*/
|
|
330
309
|
expectLengthAboveThan(targetData, lengthAboveThan, customErrorMsg = '') {
|
|
331
310
|
// @ts-ignore
|
|
332
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to have length of above ${JSON.stringify(lengthAboveThan)}`)
|
|
333
|
-
return expect(targetData, customErrorMsg).to.have.lengthOf.above(
|
|
334
|
-
lengthAboveThan,
|
|
335
|
-
);
|
|
311
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to have length of above ${JSON.stringify(lengthAboveThan)}`)
|
|
312
|
+
return expect(targetData, customErrorMsg).to.have.lengthOf.above(lengthAboveThan)
|
|
336
313
|
}
|
|
337
314
|
|
|
338
315
|
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
316
|
+
* @param {*} targetData
|
|
317
|
+
* @param {*} lengthBelowThan
|
|
318
|
+
* @param {*} [customErrorMsg]
|
|
319
|
+
*/
|
|
343
320
|
expectLengthBelowThan(targetData, lengthBelowThan, customErrorMsg = '') {
|
|
344
321
|
// @ts-ignore
|
|
345
|
-
output.step(`I expect "${JSON.stringify(targetData)}" to have length of below ${JSON.stringify(lengthBelowThan)}`)
|
|
346
|
-
return expect(targetData, customErrorMsg).to.have.lengthOf.below(
|
|
347
|
-
lengthBelowThan,
|
|
348
|
-
);
|
|
322
|
+
output.step(`I expect "${JSON.stringify(targetData)}" to have length of below ${JSON.stringify(lengthBelowThan)}`)
|
|
323
|
+
return expect(targetData, customErrorMsg).to.have.lengthOf.below(lengthBelowThan)
|
|
349
324
|
}
|
|
350
325
|
|
|
351
326
|
/**
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
327
|
+
* @param {*} actualValue
|
|
328
|
+
* @param {*} expectedValue
|
|
329
|
+
* @param {*} [customErrorMsg]
|
|
330
|
+
*/
|
|
356
331
|
expectEqualIgnoreCase(actualValue, expectedValue, customErrorMsg = '') {
|
|
357
332
|
// @ts-ignore
|
|
358
|
-
output.step(`I expect and ingore case "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`)
|
|
359
|
-
return expect(actualValue, customErrorMsg).to.equalIgnoreCase(
|
|
360
|
-
expectedValue,
|
|
361
|
-
);
|
|
333
|
+
output.step(`I expect and ingore case "${JSON.stringify(actualValue)}" to equal "${JSON.stringify(expectedValue)}"`)
|
|
334
|
+
return expect(actualValue, customErrorMsg).to.equalIgnoreCase(expectedValue)
|
|
362
335
|
}
|
|
363
336
|
|
|
364
337
|
/**
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
338
|
+
* expects members of two arrays are deeply equal
|
|
339
|
+
* @param {*} actualValue
|
|
340
|
+
* @param {*} expectedValue
|
|
341
|
+
* @param {*} [customErrorMsg]
|
|
342
|
+
*/
|
|
370
343
|
expectDeepMembers(actualValue, expectedValue, customErrorMsg = '') {
|
|
371
344
|
// @ts-ignore
|
|
372
|
-
output.step(
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
)
|
|
345
|
+
output.step(
|
|
346
|
+
`I expect members of "${JSON.stringify(actualValue)}" and "${JSON.stringify(expectedValue)}" arrays are deeply equal`,
|
|
347
|
+
)
|
|
348
|
+
return expect(actualValue, customErrorMsg).to.have.deep.members(expectedValue)
|
|
376
349
|
}
|
|
377
350
|
|
|
378
351
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
352
|
+
* expects an array to be a superset of another array
|
|
353
|
+
* @param {*} superset
|
|
354
|
+
* @param {*} set
|
|
355
|
+
* @param {*} [customErrorMsg]
|
|
356
|
+
*/
|
|
384
357
|
expectDeepIncludeMembers(superset, set, customErrorMsg = '') {
|
|
385
358
|
// @ts-ignore
|
|
386
|
-
output.step(`I expect "${JSON.stringify(superset)}" array to be a superset of "${JSON.stringify(set)}" array`)
|
|
387
|
-
return expect(superset, customErrorMsg).to.deep.include.members(
|
|
388
|
-
set,
|
|
389
|
-
);
|
|
359
|
+
output.step(`I expect "${JSON.stringify(superset)}" array to be a superset of "${JSON.stringify(set)}" array`)
|
|
360
|
+
return expect(superset, customErrorMsg).to.deep.include.members(set)
|
|
390
361
|
}
|
|
391
362
|
|
|
392
363
|
/**
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
expectDeepEqualExcluding(
|
|
400
|
-
actualValue,
|
|
401
|
-
expectedValue,
|
|
402
|
-
fieldsToExclude,
|
|
403
|
-
customErrorMsg = '',
|
|
404
|
-
) {
|
|
364
|
+
* expects members of two JSON objects are deeply equal excluding some properties
|
|
365
|
+
* @param {*} actualValue
|
|
366
|
+
* @param {*} expectedValue
|
|
367
|
+
* @param {*} fieldsToExclude
|
|
368
|
+
* @param {*} [customErrorMsg]
|
|
369
|
+
*/
|
|
370
|
+
expectDeepEqualExcluding(actualValue, expectedValue, fieldsToExclude, customErrorMsg = '') {
|
|
405
371
|
// @ts-ignore
|
|
406
|
-
output.step(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
372
|
+
output.step(
|
|
373
|
+
`I expect members of "${JSON.stringify(actualValue)}" and "${JSON.stringify(expectedValue)}" JSON objects are deeply equal excluding properties: ${JSON.stringify(fieldsToExclude)}`,
|
|
374
|
+
)
|
|
375
|
+
return expect(actualValue, customErrorMsg).excludingEvery(fieldsToExclude).to.deep.equal(expectedValue)
|
|
410
376
|
}
|
|
411
377
|
|
|
412
378
|
/**
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
379
|
+
* expects a JSON object matches a provided pattern
|
|
380
|
+
* @param {*} actualValue
|
|
381
|
+
* @param {*} expectedPattern
|
|
382
|
+
* @param {*} [customErrorMsg]
|
|
383
|
+
*/
|
|
418
384
|
expectMatchesPattern(actualValue, expectedPattern, customErrorMsg = '') {
|
|
419
385
|
// @ts-ignore
|
|
420
|
-
output.step(`I expect "${JSON.stringify(actualValue)}" to match the ${JSON.stringify(expectedPattern)} pattern`)
|
|
421
|
-
return expect(actualValue, customErrorMsg).to.matchPattern(expectedPattern)
|
|
386
|
+
output.step(`I expect "${JSON.stringify(actualValue)}" to match the ${JSON.stringify(expectedPattern)} pattern`)
|
|
387
|
+
return expect(actualValue, customErrorMsg).to.matchPattern(expectedPattern)
|
|
422
388
|
}
|
|
423
389
|
}
|
|
424
390
|
|
|
425
|
-
module.exports = ExpectHelper
|
|
391
|
+
module.exports = ExpectHelper
|