artes 1.2.16 → 1.2.18
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 +629 -533
- package/cucumber.config.js +171 -171
- package/docs/functionDefinitions.md +2401 -2401
- package/docs/stepDefinitions.md +391 -352
- package/executer.js +161 -161
- package/index.js +48 -48
- package/package.json +52 -51
- package/src/helper/contextManager/browserManager.js +63 -63
- package/src/helper/contextManager/requestManager.js +23 -23
- package/src/helper/controller/elementController.js +182 -182
- package/src/helper/controller/pomCollector.js +25 -25
- package/src/helper/executers/cleaner.js +19 -19
- package/src/helper/executers/exporter.js +15 -15
- package/src/helper/executers/helper.js +95 -95
- package/src/helper/executers/projectCreator.js +198 -198
- package/src/helper/executers/reportGenerator.js +58 -58
- package/src/helper/executers/testRunner.js +30 -30
- package/src/helper/executers/versionChecker.js +31 -31
- package/src/helper/imports/commons.js +56 -56
- package/src/helper/stepFunctions/APIActions.js +362 -362
- package/src/helper/stepFunctions/assertions.js +523 -523
- package/src/helper/stepFunctions/browserActions.js +22 -22
- package/src/helper/stepFunctions/elementInteractions.js +38 -38
- package/src/helper/stepFunctions/exporter.js +19 -19
- package/src/helper/stepFunctions/frameActions.js +50 -50
- package/src/helper/stepFunctions/keyboardActions.js +41 -41
- package/src/helper/stepFunctions/mouseActions.js +145 -145
- package/src/helper/stepFunctions/pageActions.js +27 -27
- package/src/hooks/context.js +15 -15
- package/src/hooks/hooks.js +257 -257
- package/src/stepDefinitions/API.steps.js +299 -299
- package/src/stepDefinitions/assertions.steps.js +861 -861
- package/src/stepDefinitions/browser.steps.js +7 -7
- package/src/stepDefinitions/frameActions.steps.js +76 -76
- package/src/stepDefinitions/keyboardActions.steps.js +226 -226
- package/src/stepDefinitions/mouseActions.steps.js +275 -275
- package/src/stepDefinitions/page.steps.js +71 -71
- package/src/stepDefinitions/random.steps.js +158 -158
|
@@ -1,862 +1,862 @@
|
|
|
1
|
-
const {
|
|
2
|
-
Then,
|
|
3
|
-
selector,
|
|
4
|
-
expect,
|
|
5
|
-
element,
|
|
6
|
-
extractVarsFromResponse,
|
|
7
|
-
context,
|
|
8
|
-
} = require("../helper/imports/commons");
|
|
9
|
-
const { assert, frame } = require("../helper/stepFunctions/exporter");
|
|
10
|
-
const Ajv = require("ajv");
|
|
11
|
-
|
|
12
|
-
// Check if a selector should be attached
|
|
13
|
-
Then("User expects {string} should be attached", async function (selector) {
|
|
14
|
-
await assert.shouldBeAttached(selector);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Check if a selector should be checked
|
|
18
|
-
Then("User expects {string} should be checked", async function (selector) {
|
|
19
|
-
await assert.shouldBeChecked(selector);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Check if a selector should be disabled
|
|
23
|
-
Then("User expects {string} should be disabled", async function (selector) {
|
|
24
|
-
await assert.shouldBeDisabled(selector);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Check if a selector should be editable
|
|
28
|
-
Then("User expects {string} should be editable", async function (selector) {
|
|
29
|
-
await assert.shouldBeEditable(selector);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Check if a selector should be empty
|
|
33
|
-
Then("User expects {string} should be empty", async function (selector) {
|
|
34
|
-
await assert.shouldBeEmpty(selector);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Check if a selector should be enabled
|
|
38
|
-
Then("User expects {string} should be enabled", async function (selector) {
|
|
39
|
-
await assert.shouldBeEnabled(selector);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Check if a selector should be focused
|
|
43
|
-
Then("User expects {string} should be focused", async function (selector) {
|
|
44
|
-
await assert.shouldBeFocused(selector);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Check if a selector should be hidden
|
|
48
|
-
Then("User expects {string} should be hidden", async function (selector) {
|
|
49
|
-
await assert.shouldBeHidden(selector);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Check if a selector should be in the viewport
|
|
53
|
-
Then(
|
|
54
|
-
"User expects {string} should be on the screen",
|
|
55
|
-
async function (selector) {
|
|
56
|
-
await assert.shouldBeInViewport(selector);
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Check if a selector should be visible
|
|
61
|
-
Then("User expects {string} should be visible", async function (selector) {
|
|
62
|
-
await assert.shouldBeVisible(selector);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Check if a selector should contain specific text
|
|
66
|
-
Then(
|
|
67
|
-
"User expects {string} should have {string} text",
|
|
68
|
-
async function (selector, text) {
|
|
69
|
-
await assert.shouldContainText(selector, text);
|
|
70
|
-
},
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
Then(
|
|
74
|
-
"User expects default value of {string} should have {string} text",
|
|
75
|
-
async (selector, text) => {
|
|
76
|
-
const defaultValue = await element(selector).inputValue();
|
|
77
|
-
await expect(defaultValue).toContain(text);
|
|
78
|
-
},
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
Then(
|
|
82
|
-
"User expects multiple {string} should have {string} text",
|
|
83
|
-
async (elements, expectedText) => {
|
|
84
|
-
await assert.multipleElementsShouldContainText(elements, expectedText);
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// Check if a selector should have an accessible description
|
|
89
|
-
Then(
|
|
90
|
-
"User expects {string} should have {string} description",
|
|
91
|
-
async function (selector, description) {
|
|
92
|
-
await assert.shouldHaveAccessibleDescription(selector, description);
|
|
93
|
-
},
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
// Check if a selector should have an accessible name
|
|
97
|
-
Then(
|
|
98
|
-
"User expects {string} should have {string} name",
|
|
99
|
-
async function (selector, name) {
|
|
100
|
-
await assert.shouldHaveAccessibleName(selector, name);
|
|
101
|
-
},
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
// Check if a selector should have a specific attribute with a given value
|
|
105
|
-
Then(
|
|
106
|
-
"User expects {string} should have {string} attribute with {string} value",
|
|
107
|
-
async function (selector, attribute, value) {
|
|
108
|
-
await assert.shouldHaveAttribute(selector, attribute, value);
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
// Check if a selector should have a specific class
|
|
113
|
-
Then(
|
|
114
|
-
"User expects {string} should have {string} class",
|
|
115
|
-
async function (selector, className) {
|
|
116
|
-
await assert.shouldHaveClass(selector, className);
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
// Check if a selector should have a specific count
|
|
121
|
-
Then(
|
|
122
|
-
"User expects count of {string} should be {int}",
|
|
123
|
-
async function (selector, count) {
|
|
124
|
-
await assert.shouldHaveCount(selector, count);
|
|
125
|
-
},
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
// Check if a selector should have a specific CSS property with a given value
|
|
129
|
-
Then(
|
|
130
|
-
"User expects {string} should have {string} CSS property with {string} value",
|
|
131
|
-
async function (selector, property, value) {
|
|
132
|
-
await assert.shouldHaveCSS(selector, property, value);
|
|
133
|
-
},
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
// Check if a selector should have a specific id
|
|
137
|
-
Then(
|
|
138
|
-
"User expects {string} should have {string} id",
|
|
139
|
-
async function (selector, id) {
|
|
140
|
-
await assert.shouldHaveId(selector, id);
|
|
141
|
-
},
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
// Check if a selector should have a specific JavaScript property with a given value
|
|
145
|
-
Then(
|
|
146
|
-
"User expects {string} should have {string} JavaScript property with {string} value",
|
|
147
|
-
async function (selector, property, value) {
|
|
148
|
-
await assert.shouldHaveJSProperty(selector, property, value);
|
|
149
|
-
},
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
// Check if a selector should have a specific role
|
|
153
|
-
Then(
|
|
154
|
-
"User expects {string} should have {string} role",
|
|
155
|
-
async function (selector, role) {
|
|
156
|
-
await assert.shouldHaveRole(selector, role);
|
|
157
|
-
},
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
// Check if a selector should have a screenshot
|
|
161
|
-
Then(
|
|
162
|
-
"User expects {string} should have a screenshot",
|
|
163
|
-
async function (selector) {
|
|
164
|
-
await assert.shouldHaveScreenshot(selector);
|
|
165
|
-
},
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
// Check if a selector should have specific text
|
|
169
|
-
Then(
|
|
170
|
-
"User expects {string} should match {string} text",
|
|
171
|
-
async function (selector, text) {
|
|
172
|
-
await assert.shouldHaveText(selector, text);
|
|
173
|
-
},
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
// Check if a selector should have a specific value
|
|
177
|
-
Then(
|
|
178
|
-
"User expects {string} should have {string} value",
|
|
179
|
-
async function (selector, value) {
|
|
180
|
-
await assert.shouldHaveValue(selector, value);
|
|
181
|
-
},
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
// Check if a selector should have specific values
|
|
185
|
-
Then(
|
|
186
|
-
"User expects {string} should have {string} values",
|
|
187
|
-
async function (selector, values) {
|
|
188
|
-
await assert.shouldHaveValues(selector, values.split(","));
|
|
189
|
-
},
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
// Check if the page should have a screenshot
|
|
193
|
-
Then("User expects the page should have a screenshot", async function () {
|
|
194
|
-
await assert.shouldPageHaveScreenshot();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Check if the page should have a specific title
|
|
198
|
-
Then(
|
|
199
|
-
"User expects the page should have {string} title",
|
|
200
|
-
async function (title) {
|
|
201
|
-
await assert.shouldPageHaveTitle(title);
|
|
202
|
-
},
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
// Check if the page should have a specific URL
|
|
206
|
-
Then("User expects to be in {string} page", async function (url) {
|
|
207
|
-
const URL = await selector(url);
|
|
208
|
-
await assert.shouldPageHaveURL(URL);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// Check if the response should be OK
|
|
212
|
-
Then("The response should be OK", async function (response) {
|
|
213
|
-
await assert.shouldResponseBeOK(response);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
// Check if a selector should not be attached
|
|
217
|
-
Then("User expects {string} should not be attached", async function (selector) {
|
|
218
|
-
await assert.shouldNotBeAttached(selector);
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// Check if a selector should not be checked
|
|
222
|
-
Then("User expects {string} should not be checked", async function (selector) {
|
|
223
|
-
await assert.shouldNotBeChecked(selector);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
// Check if a selector should not be disabled
|
|
227
|
-
Then("User expects {string} should not be disabled", async function (selector) {
|
|
228
|
-
await assert.shouldNotBeDisabled(selector);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
// Check if a selector should not be editable
|
|
232
|
-
Then("User expects {string} should not be editable", async function (selector) {
|
|
233
|
-
await assert.shouldNotBeEditable(selector);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
// Check if a selector should not be empty
|
|
237
|
-
Then("User expects {string} should not be empty", async function (selector) {
|
|
238
|
-
await assert.shouldNotBeEmpty(selector);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
// Check if a selector should not be enabled
|
|
242
|
-
Then("User expects {string} should not be enabled", async function (selector) {
|
|
243
|
-
await assert.shouldNotBeEnabled(selector);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
// Check if a selector should not be focused
|
|
247
|
-
Then("User expects {string} should not be focused", async function (selector) {
|
|
248
|
-
await assert.shouldNotBeFocused(selector);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
// Check if a selector should not be hidden
|
|
252
|
-
Then("User expects {string} should not be hidden", async function (selector) {
|
|
253
|
-
await assert.shouldNotBeHidden(selector);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// Check if a selector should not be in the viewport
|
|
257
|
-
Then(
|
|
258
|
-
"User expects {string} should not be on screen",
|
|
259
|
-
async function (selector) {
|
|
260
|
-
await assert.shouldNotBeInViewport(selector);
|
|
261
|
-
},
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
// Check if a selector should not be visible
|
|
265
|
-
Then("User expects {string} should not be visible", async function (selector) {
|
|
266
|
-
await assert.shouldNotBeVisible(selector);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// Check if a selector should not contain specific text
|
|
270
|
-
Then(
|
|
271
|
-
"User expects {string} should not have {string} text",
|
|
272
|
-
async function (selector, text) {
|
|
273
|
-
await assert.shouldNotContainText(selector, text);
|
|
274
|
-
},
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
// Check if a selector should not have an accessible description
|
|
278
|
-
Then(
|
|
279
|
-
"User expects {string} should not have {string} description",
|
|
280
|
-
async function (selector, description) {
|
|
281
|
-
await assert.shouldNotHaveAccessibleDescription(selector, description);
|
|
282
|
-
},
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
// Check if a selector should not have an accessible name
|
|
286
|
-
Then(
|
|
287
|
-
"User expects {string} should not have {string} name",
|
|
288
|
-
async function (selector, name) {
|
|
289
|
-
await assert.shouldNotHaveAccessibleName(selector, name);
|
|
290
|
-
},
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
// Check if a selector should not have a specific attribute with a given value
|
|
294
|
-
Then(
|
|
295
|
-
"User expects {string} should not have {string} attribute with {string} value",
|
|
296
|
-
async function (selector, attribute, value) {
|
|
297
|
-
await assert.shouldNotHaveAttribute(selector, attribute, value);
|
|
298
|
-
},
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
// Check if a selector should not have a specific class
|
|
302
|
-
Then(
|
|
303
|
-
"User expects {string} should not have {string} class",
|
|
304
|
-
async function (selector, className) {
|
|
305
|
-
await assert.shouldNotHaveClass(selector, className);
|
|
306
|
-
},
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
// Check if a selector should not have a specific count
|
|
310
|
-
Then(
|
|
311
|
-
"User expects count of {string} should not be {int}",
|
|
312
|
-
async function (selector, count) {
|
|
313
|
-
await assert.shouldNotHaveCount(selector, count);
|
|
314
|
-
},
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
// Check if a selector should not have a specific CSS property with a given value
|
|
318
|
-
Then(
|
|
319
|
-
"User expects {string} should not have {string} CSS property with {string} value",
|
|
320
|
-
async function (selector, property, value) {
|
|
321
|
-
await assert.shouldNotHaveCSS(selector, property, value);
|
|
322
|
-
},
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
// Check if a selector should not have a specific ID
|
|
326
|
-
Then(
|
|
327
|
-
"User expects {string} should not have {string} id",
|
|
328
|
-
async function (selector, id) {
|
|
329
|
-
await assert.shouldNotHaveId(selector, id);
|
|
330
|
-
},
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
// Check if a selector should not have a specific JavaScript property with a given value
|
|
334
|
-
Then(
|
|
335
|
-
"User expects {string} should not have {string} JavaScript property with {string} value",
|
|
336
|
-
async function (selector, property, value) {
|
|
337
|
-
await assert.shouldNotHaveJSProperty(selector, property, value);
|
|
338
|
-
},
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
// Check if a selector should not have a specific role
|
|
342
|
-
Then(
|
|
343
|
-
"User expects {string} should not have {string} role",
|
|
344
|
-
async function (selector, role) {
|
|
345
|
-
await assert.shouldNotHaveRole(selector, role);
|
|
346
|
-
},
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
// Check if a selector should not have specific text
|
|
350
|
-
Then(
|
|
351
|
-
"User expects {string} should not match {string} text",
|
|
352
|
-
async function (selector, text) {
|
|
353
|
-
await assert.shouldNotHaveText(selector, text);
|
|
354
|
-
},
|
|
355
|
-
);
|
|
356
|
-
|
|
357
|
-
// Check if a selector should not have a specific value
|
|
358
|
-
Then(
|
|
359
|
-
"User expects {string} should not have {string} value",
|
|
360
|
-
async function (selector, value) {
|
|
361
|
-
await assert.shouldNotHaveValue(selector, value);
|
|
362
|
-
},
|
|
363
|
-
);
|
|
364
|
-
|
|
365
|
-
// Check if a selector should not have specific values
|
|
366
|
-
Then(
|
|
367
|
-
"User expects {string} should not have {string} values",
|
|
368
|
-
async function (selector, values) {
|
|
369
|
-
await assert.shouldNotHaveValues(selector, values.split(","));
|
|
370
|
-
},
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
// Check if the page should not have a screenshot
|
|
374
|
-
Then("User expects the page should not have a screenshot", async function () {
|
|
375
|
-
await assert.shouldNotPageHaveScreenshot();
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
// Check if the page should not have a specific title
|
|
379
|
-
Then(
|
|
380
|
-
"User expects the page should not have {string} title",
|
|
381
|
-
async function (title) {
|
|
382
|
-
await assert.shouldNotPageHaveTitle(title);
|
|
383
|
-
},
|
|
384
|
-
);
|
|
385
|
-
|
|
386
|
-
// Check if the page should not have a specific URL
|
|
387
|
-
Then("User expects the page url should not be {string}", async function (url) {
|
|
388
|
-
await assert.shouldNotPageHaveURL(url);
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
Then("User is not on {string} page", async function (url) {
|
|
392
|
-
await assert.shouldNotPageHaveURL(url);
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
// Check if a response should not be OK
|
|
396
|
-
Then("The response should not be OK", async function (response) {
|
|
397
|
-
await assert.shouldNotResponseBeOK(response);
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// Check if a selector's value should be equal to the expected value
|
|
401
|
-
Then(
|
|
402
|
-
"User expects {string} should be {string} text",
|
|
403
|
-
async function (selector, expected) {
|
|
404
|
-
await assert.shouldBe(selector, expected);
|
|
405
|
-
},
|
|
406
|
-
);
|
|
407
|
-
|
|
408
|
-
// Check if a selector's value should be close to the expected value within a precision
|
|
409
|
-
Then(
|
|
410
|
-
"User expects {string} should be close to {float} with precision {int}",
|
|
411
|
-
async function (selector, expected, precision) {
|
|
412
|
-
await assert.shouldBeCloseTo(selector, expected, precision);
|
|
413
|
-
},
|
|
414
|
-
);
|
|
415
|
-
|
|
416
|
-
// Check if a selector's value should be defined
|
|
417
|
-
Then("User expects {string} should be defined", async function (selector) {
|
|
418
|
-
await assert.shouldBeDefined(selector);
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
// Check if a selector's text content should be falsy
|
|
422
|
-
Then("User expects {string} should be falsy", async function (selector) {
|
|
423
|
-
await assert.shouldBeFalsy(selector);
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
// Check if a selector's value should be greater than the expected value
|
|
427
|
-
Then(
|
|
428
|
-
"User expects {string} should be greater than {float}",
|
|
429
|
-
async function (selector, expected) {
|
|
430
|
-
await assert.shouldBeGreaterThan(selector, expected);
|
|
431
|
-
},
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
// Check if a selector's value should be greater than or equal to the expected value
|
|
435
|
-
Then(
|
|
436
|
-
"User expects {string} should be greater than or equal to {float}",
|
|
437
|
-
async function (selector, expected) {
|
|
438
|
-
await assert.shouldBeGreaterThanOrEqual(selector, expected);
|
|
439
|
-
},
|
|
440
|
-
);
|
|
441
|
-
|
|
442
|
-
// Check if a selector's value should be an instance of a specific constructor
|
|
443
|
-
Then(
|
|
444
|
-
"User expects {string} should be an instance of {string}",
|
|
445
|
-
async function (selector, constructor) {
|
|
446
|
-
await assert.shouldBeInstanceOf(selector, constructor);
|
|
447
|
-
},
|
|
448
|
-
);
|
|
449
|
-
|
|
450
|
-
// Check if a selector's value should be less than the expected value
|
|
451
|
-
Then(
|
|
452
|
-
"User expects {string} should be less than {float}",
|
|
453
|
-
async function (selector, expected) {
|
|
454
|
-
await assert.shouldBeLessThan(selector, expected);
|
|
455
|
-
},
|
|
456
|
-
);
|
|
457
|
-
|
|
458
|
-
// Check if a selector's value should be less than or equal to the expected value
|
|
459
|
-
Then(
|
|
460
|
-
"User expects {string} should be less than or equal to {float}",
|
|
461
|
-
async function (selector, expected) {
|
|
462
|
-
await assert.shouldBeLessThanOrEqual(selector, expected);
|
|
463
|
-
},
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
// Check if a selector's value should be NaN
|
|
467
|
-
Then("User expects {string} should be NaN", async function (selector) {
|
|
468
|
-
await assert.shouldBeNaN(selector);
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
// Check if a selector's value should be null
|
|
472
|
-
Then("User expects {string} should be null", async function (selector) {
|
|
473
|
-
await assert.shouldBeNull(selector);
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
// Check if a selector's value should be truthy
|
|
477
|
-
Then("User expects {string} should be truthy", async function (selector) {
|
|
478
|
-
await assert.shouldBeTruthy(selector);
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
// Check if a selector's value should be undefined
|
|
482
|
-
Then("User expects {string} should be undefined", async function (selector) {
|
|
483
|
-
await assert.shouldBeUndefined(selector);
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
// Check if a selector's value should contain a specific substring
|
|
487
|
-
Then(
|
|
488
|
-
"User expects {string} should have {string} substring",
|
|
489
|
-
async function (selector, substring) {
|
|
490
|
-
await assert.shouldContain(selector, substring);
|
|
491
|
-
},
|
|
492
|
-
);
|
|
493
|
-
|
|
494
|
-
// Check if a selector's value should contain an equal value
|
|
495
|
-
Then(
|
|
496
|
-
"User expects {string} should contain equal {string}",
|
|
497
|
-
async function (selector, expected) {
|
|
498
|
-
await assert.shouldContainEqual(selector, expected);
|
|
499
|
-
},
|
|
500
|
-
);
|
|
501
|
-
|
|
502
|
-
// Check if a selector's value should equal the expected value
|
|
503
|
-
Then(
|
|
504
|
-
"User expects {string} should equal {int}",
|
|
505
|
-
async function (selector, expected) {
|
|
506
|
-
await assert.shouldEqual(selector, expected);
|
|
507
|
-
},
|
|
508
|
-
);
|
|
509
|
-
|
|
510
|
-
// Check if a selector's text content should have a specific length
|
|
511
|
-
Then(
|
|
512
|
-
"User expects length of {string} should be {int}",
|
|
513
|
-
async function (selector, length) {
|
|
514
|
-
await assert.shouldHaveLength(selector, length);
|
|
515
|
-
},
|
|
516
|
-
);
|
|
517
|
-
|
|
518
|
-
// Check if a selector's text content should have a specific property
|
|
519
|
-
Then(
|
|
520
|
-
"User expects {string} should have {string} property",
|
|
521
|
-
async function (selector, property) {
|
|
522
|
-
await assert.shouldHaveProperty(selector, property);
|
|
523
|
-
},
|
|
524
|
-
);
|
|
525
|
-
|
|
526
|
-
// Check if a selector's text content should match a specific regex
|
|
527
|
-
Then(
|
|
528
|
-
"User expects {string} should match {string} regex",
|
|
529
|
-
async function (selector, regex) {
|
|
530
|
-
await assert.shouldMatch(selector, new RegExp(regex));
|
|
531
|
-
},
|
|
532
|
-
);
|
|
533
|
-
|
|
534
|
-
// Check if a selector's text content should match a specific object
|
|
535
|
-
Then(
|
|
536
|
-
"User expects {string} should match {string} object",
|
|
537
|
-
async function (selector, object) {
|
|
538
|
-
await assert.shouldMatchObject(selector, JSON.parse(object));
|
|
539
|
-
},
|
|
540
|
-
);
|
|
541
|
-
|
|
542
|
-
// Check if a selector's text content should strictly equal the expected value
|
|
543
|
-
Then(
|
|
544
|
-
"User expects {string} should strictly equal {string}",
|
|
545
|
-
async function (selector, expected) {
|
|
546
|
-
await assert.shouldStrictEqual(selector, expected);
|
|
547
|
-
},
|
|
548
|
-
);
|
|
549
|
-
|
|
550
|
-
// Check if a async function should throw an error
|
|
551
|
-
Then("The async function should throw", async function (fn) {
|
|
552
|
-
await assert.shouldThrow(fn);
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
// Check if the text content of a selector should be an instance of a specific constructor
|
|
556
|
-
Then(
|
|
557
|
-
"User expects {string} should be any instance of {string}",
|
|
558
|
-
async function (selector, constructor) {
|
|
559
|
-
await assert.shouldAny(selector, constructor);
|
|
560
|
-
},
|
|
561
|
-
);
|
|
562
|
-
|
|
563
|
-
// Check if the text content of a selector may be anything (truthy)
|
|
564
|
-
Then("User expects {string} may be anything", async function (selector) {
|
|
565
|
-
await assert.shouldAnything(selector);
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
// Check if the text content of a selector should contain any of the specified elements in an array
|
|
569
|
-
Then(
|
|
570
|
-
"User expects {string} should contain {string} array elements",
|
|
571
|
-
async function (selector, elements) {
|
|
572
|
-
const parsedElements = elements.split(",");
|
|
573
|
-
await assert.shouldArrayContaining(selector, parsedElements);
|
|
574
|
-
},
|
|
575
|
-
);
|
|
576
|
-
|
|
577
|
-
// Check if the text content of a selector should be close to the expected value within a precision
|
|
578
|
-
Then(
|
|
579
|
-
"User expects {string} should be close to {float} with precision {int}",
|
|
580
|
-
async function (selector, expected, precision) {
|
|
581
|
-
await assert.shouldCloseTo(selector, expected, precision);
|
|
582
|
-
},
|
|
583
|
-
);
|
|
584
|
-
|
|
585
|
-
// Check if the text content of a selector should contain the specified properties in an object
|
|
586
|
-
Then(
|
|
587
|
-
"User expects {string} should contain {string} object properties",
|
|
588
|
-
async function (selector, properties) {
|
|
589
|
-
const parsedProperties = properties.split(",");
|
|
590
|
-
await assert.shouldObjectContaining(selector, parsedProperties);
|
|
591
|
-
},
|
|
592
|
-
);
|
|
593
|
-
|
|
594
|
-
// Check if the text content of a selector should contain a specific substring
|
|
595
|
-
Then(
|
|
596
|
-
"User expects {string} should have {string} substring",
|
|
597
|
-
async function (selector, substring) {
|
|
598
|
-
await assert.shouldStringContaining(selector, substring);
|
|
599
|
-
},
|
|
600
|
-
);
|
|
601
|
-
|
|
602
|
-
// Check if the text content of a selector should match a specific regex
|
|
603
|
-
Then(
|
|
604
|
-
"User expects {string} should match {string} regex",
|
|
605
|
-
async function (selector, regex) {
|
|
606
|
-
await assert.shouldStringMatching(selector, new RegExp(regex));
|
|
607
|
-
},
|
|
608
|
-
);
|
|
609
|
-
|
|
610
|
-
// Check if a selector's text content should not be equal to the expected value
|
|
611
|
-
Then(
|
|
612
|
-
"User expects {string} should not be {string} text",
|
|
613
|
-
async function (selector, expected) {
|
|
614
|
-
await assert.shouldNotBe(selector, expected);
|
|
615
|
-
},
|
|
616
|
-
);
|
|
617
|
-
|
|
618
|
-
// Check if a selector's text content should not be close to the expected value within a precision
|
|
619
|
-
Then(
|
|
620
|
-
"User expects {string} should not be close to {float} with precision {int}",
|
|
621
|
-
async function (selector, expected, precision) {
|
|
622
|
-
await assert.shouldNotBeCloseTo(selector, expected, precision);
|
|
623
|
-
},
|
|
624
|
-
);
|
|
625
|
-
|
|
626
|
-
// Check if a selector's text content should not be defined
|
|
627
|
-
Then("User expects {string} should not be defined", async function (selector) {
|
|
628
|
-
await assert.shouldNotBeDefined(selector);
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
// Check if a selector's text content should not be falsy
|
|
632
|
-
Then("User expects {string} should not be falsy", async function (selector) {
|
|
633
|
-
await assert.shouldNotBeFalsy(selector);
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
// Check if a selector's text content should not be greater than the expected value
|
|
637
|
-
Then(
|
|
638
|
-
"User expects {string} should not be greater than {float}",
|
|
639
|
-
async function (selector, expected) {
|
|
640
|
-
await assert.shouldNotBeGreaterThan(selector, expected);
|
|
641
|
-
},
|
|
642
|
-
);
|
|
643
|
-
|
|
644
|
-
// Check if a selector's text content should not be greater than or equal to the expected value
|
|
645
|
-
Then(
|
|
646
|
-
"User expects {string} should not be greater than or equal to {float}",
|
|
647
|
-
async function (selector, expected) {
|
|
648
|
-
await assert.shouldNotBeGreaterThanOrEqual(selector, expected);
|
|
649
|
-
},
|
|
650
|
-
);
|
|
651
|
-
|
|
652
|
-
// Check if a selector's text content should not be an instance of a specific constructor
|
|
653
|
-
Then(
|
|
654
|
-
"User expects {string} should not be an instance of {string}",
|
|
655
|
-
async function (selector, constructor) {
|
|
656
|
-
await assert.shouldNotBeInstanceOf(selector, constructor);
|
|
657
|
-
},
|
|
658
|
-
);
|
|
659
|
-
|
|
660
|
-
// Check if a selector's text content should not be less than the expected value
|
|
661
|
-
Then(
|
|
662
|
-
"User expects {string} should not be less than {float}",
|
|
663
|
-
async function (selector, expected) {
|
|
664
|
-
await assert.shouldNotBeLessThan(selector, expected);
|
|
665
|
-
},
|
|
666
|
-
);
|
|
667
|
-
|
|
668
|
-
// Check if a selector's text content should not be less than or equal to the expected value
|
|
669
|
-
Then(
|
|
670
|
-
"User expects {string} should not be less than or equal to {float}",
|
|
671
|
-
async function (selector, expected) {
|
|
672
|
-
await assert.shouldNotBeLessThanOrEqual(selector, expected);
|
|
673
|
-
},
|
|
674
|
-
);
|
|
675
|
-
|
|
676
|
-
// Check if a selector's text content should not be NaN
|
|
677
|
-
Then("User expects {string} should not be NaN", async function (selector) {
|
|
678
|
-
await assert.shouldNotBeNaN(selector);
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
// Check if a selector's text content should not be null
|
|
682
|
-
Then("User expects {string} should not be null", async function (selector) {
|
|
683
|
-
await assert.shouldNotBeNull(selector);
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
// Check if a selector's text content should not be truthy
|
|
687
|
-
Then("User expects {string} should not be truthy", async function (selector) {
|
|
688
|
-
await assert.shouldNotBeTruthy(selector);
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
// Check if a selector's text content should not be undefined
|
|
692
|
-
Then(
|
|
693
|
-
"User expects {string} should not be undefined",
|
|
694
|
-
async function (selector) {
|
|
695
|
-
await assert.shouldNotBeUndefined(selector);
|
|
696
|
-
},
|
|
697
|
-
);
|
|
698
|
-
|
|
699
|
-
// Check if a selector's text content should not contain a specific substring
|
|
700
|
-
Then(
|
|
701
|
-
"User expects {string} should not have {string} substring",
|
|
702
|
-
async function (selector, substring) {
|
|
703
|
-
await assert.shouldNotContain(selector, substring);
|
|
704
|
-
},
|
|
705
|
-
);
|
|
706
|
-
|
|
707
|
-
// Check if a selector's text content should not contain an equal value
|
|
708
|
-
Then(
|
|
709
|
-
"User expects {string} should not contain equal {string}",
|
|
710
|
-
async function (selector, expected) {
|
|
711
|
-
await assert.shouldNotContainEqual(selector, expected);
|
|
712
|
-
},
|
|
713
|
-
);
|
|
714
|
-
|
|
715
|
-
// Check if a selector's text content should not equal the expected value
|
|
716
|
-
Then(
|
|
717
|
-
"User expects {string} should not equal {string}",
|
|
718
|
-
async function (selector, expected) {
|
|
719
|
-
await assert.shouldNotEqual(selector, expected);
|
|
720
|
-
},
|
|
721
|
-
);
|
|
722
|
-
|
|
723
|
-
// Check if a selector's text content should not have a specific length
|
|
724
|
-
Then(
|
|
725
|
-
"User expects length of {string} should not be {int} ",
|
|
726
|
-
async function (selector, length) {
|
|
727
|
-
await assert.shouldNotHaveLength(selector, length);
|
|
728
|
-
},
|
|
729
|
-
);
|
|
730
|
-
|
|
731
|
-
// Check if a selector's text content should not have a specific property
|
|
732
|
-
Then(
|
|
733
|
-
"User expects {string} should not have {string} property",
|
|
734
|
-
async function (selector, property) {
|
|
735
|
-
await assert.shouldNotHaveProperty(selector, property);
|
|
736
|
-
},
|
|
737
|
-
);
|
|
738
|
-
|
|
739
|
-
// Check if a selector's text content should not match a specific regex
|
|
740
|
-
Then(
|
|
741
|
-
"User expects {string} should not match {string} regex",
|
|
742
|
-
async function (selector, regex) {
|
|
743
|
-
await assert.shouldNotMatch(selector, new RegExp(regex));
|
|
744
|
-
},
|
|
745
|
-
);
|
|
746
|
-
|
|
747
|
-
// Check if a selector's text content should not match a specific object
|
|
748
|
-
Then(
|
|
749
|
-
"User expects {string} should not match {string} object",
|
|
750
|
-
async function (selector, object) {
|
|
751
|
-
await assert.shouldNotMatchObject(selector, JSON.parse(object));
|
|
752
|
-
},
|
|
753
|
-
);
|
|
754
|
-
|
|
755
|
-
// Check if a async function should not throw an error
|
|
756
|
-
Then("The async function should not throw", async function (fn) {
|
|
757
|
-
await assert.shouldNotThrow(fn);
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
// Check if a selector's text content should not be any instance of a specific constructor
|
|
761
|
-
Then(
|
|
762
|
-
"User expects {string} should not be any instance of {string}",
|
|
763
|
-
async function (selector, constructor) {
|
|
764
|
-
await assert.shouldNotAny(selector, constructor);
|
|
765
|
-
},
|
|
766
|
-
);
|
|
767
|
-
|
|
768
|
-
// Check if a selector's text content may not be anything (falsy)
|
|
769
|
-
Then("User expects {string} may not be anything", async function (selector) {
|
|
770
|
-
await assert.shouldNotAnything(selector);
|
|
771
|
-
});
|
|
772
|
-
|
|
773
|
-
// Check if a selector's text content should not contain any of the specified elements in an array
|
|
774
|
-
Then(
|
|
775
|
-
"User expects {string} should not contain {string} array elements",
|
|
776
|
-
async function (selector, elements) {
|
|
777
|
-
const parsedElements = elements.split(",");
|
|
778
|
-
await assert.shouldNotArrayContaining(selector, parsedElements);
|
|
779
|
-
},
|
|
780
|
-
);
|
|
781
|
-
|
|
782
|
-
// Check if a selector's text content should not be close to the expected value within a precision
|
|
783
|
-
Then(
|
|
784
|
-
"User expects {string} should not be close to {float} with precision {int}",
|
|
785
|
-
async function (selector, expected, precision) {
|
|
786
|
-
await assert.shouldNotCloseTo(selector, expected, precision);
|
|
787
|
-
},
|
|
788
|
-
);
|
|
789
|
-
|
|
790
|
-
// Check if a selector's text content should not contain the specified properties in an object
|
|
791
|
-
Then(
|
|
792
|
-
"User expects {string} should not contain {string} object properties",
|
|
793
|
-
async function (selector, properties) {
|
|
794
|
-
const parsedProperties = JSON.parse(properties);
|
|
795
|
-
await assert.shouldNotObjectContaining(selector, parsedProperties);
|
|
796
|
-
},
|
|
797
|
-
);
|
|
798
|
-
|
|
799
|
-
// Check if a selector's text content should not contain a specific substring
|
|
800
|
-
Then(
|
|
801
|
-
"User expects {string} should not contain {string} substring",
|
|
802
|
-
async function (selector, substring) {
|
|
803
|
-
await assert.shouldNotStringContaining(selector, substring);
|
|
804
|
-
},
|
|
805
|
-
);
|
|
806
|
-
|
|
807
|
-
// Check if a selector's text content should not match a specific regex
|
|
808
|
-
Then(
|
|
809
|
-
"User expects {string} should not match {string} regex",
|
|
810
|
-
async function (selector, regex) {
|
|
811
|
-
await assert.shouldNotStringMatching(selector, new RegExp(regex));
|
|
812
|
-
},
|
|
813
|
-
);
|
|
814
|
-
|
|
815
|
-
Then("User expects should have {int} {string}", async (count, elements) => {
|
|
816
|
-
const elementCount = await frame.count(elements);
|
|
817
|
-
expect(elementCount).toEqual(count);
|
|
818
|
-
});
|
|
819
|
-
|
|
820
|
-
Then(
|
|
821
|
-
"User expects that response has {string} field with {string} value",
|
|
822
|
-
async (field, value) => {
|
|
823
|
-
extractVarsFromResponse(context.response["Response Body"], field);
|
|
824
|
-
const varToString = JSON.stringify(context.vars[field]);
|
|
825
|
-
expect(varToString).toBe(value);
|
|
826
|
-
},
|
|
827
|
-
);
|
|
828
|
-
|
|
829
|
-
Then('User expects that {string} should match {string}', async (value1, value2) => {
|
|
830
|
-
await expect(resolveVariable(value1)).toBe(value2)
|
|
831
|
-
})
|
|
832
|
-
|
|
833
|
-
Then(
|
|
834
|
-
"User expects that response body should match {string} schema",
|
|
835
|
-
async function (expectedSchema) {
|
|
836
|
-
if(expectedSchema !="" ){
|
|
837
|
-
const schema = await selector(expectedSchema);
|
|
838
|
-
const ajv = await new Ajv();
|
|
839
|
-
const validate = await ajv.compile(schema);
|
|
840
|
-
const responseBody = await context.response["Response Body"];
|
|
841
|
-
const valid = await validate(responseBody);
|
|
842
|
-
await expect(valid).toBe(true);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
);
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
Then(
|
|
849
|
-
"User expects that request should have {int} status code",
|
|
850
|
-
async function (expectedStatusCode) {
|
|
851
|
-
const actualStatusCode = await context.response.Response.status();
|
|
852
|
-
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
853
|
-
}
|
|
854
|
-
);
|
|
855
|
-
|
|
856
|
-
Then(
|
|
857
|
-
"User expects that response should have {int} status code",
|
|
858
|
-
async function (expectedStatusCode) {
|
|
859
|
-
const actualStatusCode = await context.response.Response.status();
|
|
860
|
-
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
861
|
-
}
|
|
1
|
+
const {
|
|
2
|
+
Then,
|
|
3
|
+
selector,
|
|
4
|
+
expect,
|
|
5
|
+
element,
|
|
6
|
+
extractVarsFromResponse,
|
|
7
|
+
context,
|
|
8
|
+
} = require("../helper/imports/commons");
|
|
9
|
+
const { assert, frame } = require("../helper/stepFunctions/exporter");
|
|
10
|
+
const Ajv = require("ajv");
|
|
11
|
+
|
|
12
|
+
// Check if a selector should be attached
|
|
13
|
+
Then("User expects {string} should be attached", async function (selector) {
|
|
14
|
+
await assert.shouldBeAttached(selector);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Check if a selector should be checked
|
|
18
|
+
Then("User expects {string} should be checked", async function (selector) {
|
|
19
|
+
await assert.shouldBeChecked(selector);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Check if a selector should be disabled
|
|
23
|
+
Then("User expects {string} should be disabled", async function (selector) {
|
|
24
|
+
await assert.shouldBeDisabled(selector);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Check if a selector should be editable
|
|
28
|
+
Then("User expects {string} should be editable", async function (selector) {
|
|
29
|
+
await assert.shouldBeEditable(selector);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Check if a selector should be empty
|
|
33
|
+
Then("User expects {string} should be empty", async function (selector) {
|
|
34
|
+
await assert.shouldBeEmpty(selector);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Check if a selector should be enabled
|
|
38
|
+
Then("User expects {string} should be enabled", async function (selector) {
|
|
39
|
+
await assert.shouldBeEnabled(selector);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Check if a selector should be focused
|
|
43
|
+
Then("User expects {string} should be focused", async function (selector) {
|
|
44
|
+
await assert.shouldBeFocused(selector);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Check if a selector should be hidden
|
|
48
|
+
Then("User expects {string} should be hidden", async function (selector) {
|
|
49
|
+
await assert.shouldBeHidden(selector);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Check if a selector should be in the viewport
|
|
53
|
+
Then(
|
|
54
|
+
"User expects {string} should be on the screen",
|
|
55
|
+
async function (selector) {
|
|
56
|
+
await assert.shouldBeInViewport(selector);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Check if a selector should be visible
|
|
61
|
+
Then("User expects {string} should be visible", async function (selector) {
|
|
62
|
+
await assert.shouldBeVisible(selector);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Check if a selector should contain specific text
|
|
66
|
+
Then(
|
|
67
|
+
"User expects {string} should have {string} text",
|
|
68
|
+
async function (selector, text) {
|
|
69
|
+
await assert.shouldContainText(selector, text);
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
Then(
|
|
74
|
+
"User expects default value of {string} should have {string} text",
|
|
75
|
+
async (selector, text) => {
|
|
76
|
+
const defaultValue = await element(selector).inputValue();
|
|
77
|
+
await expect(defaultValue).toContain(text);
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
Then(
|
|
82
|
+
"User expects multiple {string} should have {string} text",
|
|
83
|
+
async (elements, expectedText) => {
|
|
84
|
+
await assert.multipleElementsShouldContainText(elements, expectedText);
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Check if a selector should have an accessible description
|
|
89
|
+
Then(
|
|
90
|
+
"User expects {string} should have {string} description",
|
|
91
|
+
async function (selector, description) {
|
|
92
|
+
await assert.shouldHaveAccessibleDescription(selector, description);
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// Check if a selector should have an accessible name
|
|
97
|
+
Then(
|
|
98
|
+
"User expects {string} should have {string} name",
|
|
99
|
+
async function (selector, name) {
|
|
100
|
+
await assert.shouldHaveAccessibleName(selector, name);
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Check if a selector should have a specific attribute with a given value
|
|
105
|
+
Then(
|
|
106
|
+
"User expects {string} should have {string} attribute with {string} value",
|
|
107
|
+
async function (selector, attribute, value) {
|
|
108
|
+
await assert.shouldHaveAttribute(selector, attribute, value);
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Check if a selector should have a specific class
|
|
113
|
+
Then(
|
|
114
|
+
"User expects {string} should have {string} class",
|
|
115
|
+
async function (selector, className) {
|
|
116
|
+
await assert.shouldHaveClass(selector, className);
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// Check if a selector should have a specific count
|
|
121
|
+
Then(
|
|
122
|
+
"User expects count of {string} should be {int}",
|
|
123
|
+
async function (selector, count) {
|
|
124
|
+
await assert.shouldHaveCount(selector, count);
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// Check if a selector should have a specific CSS property with a given value
|
|
129
|
+
Then(
|
|
130
|
+
"User expects {string} should have {string} CSS property with {string} value",
|
|
131
|
+
async function (selector, property, value) {
|
|
132
|
+
await assert.shouldHaveCSS(selector, property, value);
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
// Check if a selector should have a specific id
|
|
137
|
+
Then(
|
|
138
|
+
"User expects {string} should have {string} id",
|
|
139
|
+
async function (selector, id) {
|
|
140
|
+
await assert.shouldHaveId(selector, id);
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
// Check if a selector should have a specific JavaScript property with a given value
|
|
145
|
+
Then(
|
|
146
|
+
"User expects {string} should have {string} JavaScript property with {string} value",
|
|
147
|
+
async function (selector, property, value) {
|
|
148
|
+
await assert.shouldHaveJSProperty(selector, property, value);
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
// Check if a selector should have a specific role
|
|
153
|
+
Then(
|
|
154
|
+
"User expects {string} should have {string} role",
|
|
155
|
+
async function (selector, role) {
|
|
156
|
+
await assert.shouldHaveRole(selector, role);
|
|
157
|
+
},
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// Check if a selector should have a screenshot
|
|
161
|
+
Then(
|
|
162
|
+
"User expects {string} should have a screenshot",
|
|
163
|
+
async function (selector) {
|
|
164
|
+
await assert.shouldHaveScreenshot(selector);
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
// Check if a selector should have specific text
|
|
169
|
+
Then(
|
|
170
|
+
"User expects {string} should match {string} text",
|
|
171
|
+
async function (selector, text) {
|
|
172
|
+
await assert.shouldHaveText(selector, text);
|
|
173
|
+
},
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
// Check if a selector should have a specific value
|
|
177
|
+
Then(
|
|
178
|
+
"User expects {string} should have {string} value",
|
|
179
|
+
async function (selector, value) {
|
|
180
|
+
await assert.shouldHaveValue(selector, value);
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
// Check if a selector should have specific values
|
|
185
|
+
Then(
|
|
186
|
+
"User expects {string} should have {string} values",
|
|
187
|
+
async function (selector, values) {
|
|
188
|
+
await assert.shouldHaveValues(selector, values.split(","));
|
|
189
|
+
},
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// Check if the page should have a screenshot
|
|
193
|
+
Then("User expects the page should have a screenshot", async function () {
|
|
194
|
+
await assert.shouldPageHaveScreenshot();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Check if the page should have a specific title
|
|
198
|
+
Then(
|
|
199
|
+
"User expects the page should have {string} title",
|
|
200
|
+
async function (title) {
|
|
201
|
+
await assert.shouldPageHaveTitle(title);
|
|
202
|
+
},
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
// Check if the page should have a specific URL
|
|
206
|
+
Then("User expects to be in {string} page", async function (url) {
|
|
207
|
+
const URL = await selector(url);
|
|
208
|
+
await assert.shouldPageHaveURL(URL);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Check if the response should be OK
|
|
212
|
+
Then("The response should be OK", async function (response) {
|
|
213
|
+
await assert.shouldResponseBeOK(response);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// Check if a selector should not be attached
|
|
217
|
+
Then("User expects {string} should not be attached", async function (selector) {
|
|
218
|
+
await assert.shouldNotBeAttached(selector);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Check if a selector should not be checked
|
|
222
|
+
Then("User expects {string} should not be checked", async function (selector) {
|
|
223
|
+
await assert.shouldNotBeChecked(selector);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// Check if a selector should not be disabled
|
|
227
|
+
Then("User expects {string} should not be disabled", async function (selector) {
|
|
228
|
+
await assert.shouldNotBeDisabled(selector);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Check if a selector should not be editable
|
|
232
|
+
Then("User expects {string} should not be editable", async function (selector) {
|
|
233
|
+
await assert.shouldNotBeEditable(selector);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Check if a selector should not be empty
|
|
237
|
+
Then("User expects {string} should not be empty", async function (selector) {
|
|
238
|
+
await assert.shouldNotBeEmpty(selector);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Check if a selector should not be enabled
|
|
242
|
+
Then("User expects {string} should not be enabled", async function (selector) {
|
|
243
|
+
await assert.shouldNotBeEnabled(selector);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Check if a selector should not be focused
|
|
247
|
+
Then("User expects {string} should not be focused", async function (selector) {
|
|
248
|
+
await assert.shouldNotBeFocused(selector);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// Check if a selector should not be hidden
|
|
252
|
+
Then("User expects {string} should not be hidden", async function (selector) {
|
|
253
|
+
await assert.shouldNotBeHidden(selector);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// Check if a selector should not be in the viewport
|
|
257
|
+
Then(
|
|
258
|
+
"User expects {string} should not be on screen",
|
|
259
|
+
async function (selector) {
|
|
260
|
+
await assert.shouldNotBeInViewport(selector);
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
// Check if a selector should not be visible
|
|
265
|
+
Then("User expects {string} should not be visible", async function (selector) {
|
|
266
|
+
await assert.shouldNotBeVisible(selector);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Check if a selector should not contain specific text
|
|
270
|
+
Then(
|
|
271
|
+
"User expects {string} should not have {string} text",
|
|
272
|
+
async function (selector, text) {
|
|
273
|
+
await assert.shouldNotContainText(selector, text);
|
|
274
|
+
},
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
// Check if a selector should not have an accessible description
|
|
278
|
+
Then(
|
|
279
|
+
"User expects {string} should not have {string} description",
|
|
280
|
+
async function (selector, description) {
|
|
281
|
+
await assert.shouldNotHaveAccessibleDescription(selector, description);
|
|
282
|
+
},
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
// Check if a selector should not have an accessible name
|
|
286
|
+
Then(
|
|
287
|
+
"User expects {string} should not have {string} name",
|
|
288
|
+
async function (selector, name) {
|
|
289
|
+
await assert.shouldNotHaveAccessibleName(selector, name);
|
|
290
|
+
},
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
// Check if a selector should not have a specific attribute with a given value
|
|
294
|
+
Then(
|
|
295
|
+
"User expects {string} should not have {string} attribute with {string} value",
|
|
296
|
+
async function (selector, attribute, value) {
|
|
297
|
+
await assert.shouldNotHaveAttribute(selector, attribute, value);
|
|
298
|
+
},
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
// Check if a selector should not have a specific class
|
|
302
|
+
Then(
|
|
303
|
+
"User expects {string} should not have {string} class",
|
|
304
|
+
async function (selector, className) {
|
|
305
|
+
await assert.shouldNotHaveClass(selector, className);
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
// Check if a selector should not have a specific count
|
|
310
|
+
Then(
|
|
311
|
+
"User expects count of {string} should not be {int}",
|
|
312
|
+
async function (selector, count) {
|
|
313
|
+
await assert.shouldNotHaveCount(selector, count);
|
|
314
|
+
},
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
// Check if a selector should not have a specific CSS property with a given value
|
|
318
|
+
Then(
|
|
319
|
+
"User expects {string} should not have {string} CSS property with {string} value",
|
|
320
|
+
async function (selector, property, value) {
|
|
321
|
+
await assert.shouldNotHaveCSS(selector, property, value);
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
// Check if a selector should not have a specific ID
|
|
326
|
+
Then(
|
|
327
|
+
"User expects {string} should not have {string} id",
|
|
328
|
+
async function (selector, id) {
|
|
329
|
+
await assert.shouldNotHaveId(selector, id);
|
|
330
|
+
},
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
// Check if a selector should not have a specific JavaScript property with a given value
|
|
334
|
+
Then(
|
|
335
|
+
"User expects {string} should not have {string} JavaScript property with {string} value",
|
|
336
|
+
async function (selector, property, value) {
|
|
337
|
+
await assert.shouldNotHaveJSProperty(selector, property, value);
|
|
338
|
+
},
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
// Check if a selector should not have a specific role
|
|
342
|
+
Then(
|
|
343
|
+
"User expects {string} should not have {string} role",
|
|
344
|
+
async function (selector, role) {
|
|
345
|
+
await assert.shouldNotHaveRole(selector, role);
|
|
346
|
+
},
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
// Check if a selector should not have specific text
|
|
350
|
+
Then(
|
|
351
|
+
"User expects {string} should not match {string} text",
|
|
352
|
+
async function (selector, text) {
|
|
353
|
+
await assert.shouldNotHaveText(selector, text);
|
|
354
|
+
},
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
// Check if a selector should not have a specific value
|
|
358
|
+
Then(
|
|
359
|
+
"User expects {string} should not have {string} value",
|
|
360
|
+
async function (selector, value) {
|
|
361
|
+
await assert.shouldNotHaveValue(selector, value);
|
|
362
|
+
},
|
|
363
|
+
);
|
|
364
|
+
|
|
365
|
+
// Check if a selector should not have specific values
|
|
366
|
+
Then(
|
|
367
|
+
"User expects {string} should not have {string} values",
|
|
368
|
+
async function (selector, values) {
|
|
369
|
+
await assert.shouldNotHaveValues(selector, values.split(","));
|
|
370
|
+
},
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
// Check if the page should not have a screenshot
|
|
374
|
+
Then("User expects the page should not have a screenshot", async function () {
|
|
375
|
+
await assert.shouldNotPageHaveScreenshot();
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
// Check if the page should not have a specific title
|
|
379
|
+
Then(
|
|
380
|
+
"User expects the page should not have {string} title",
|
|
381
|
+
async function (title) {
|
|
382
|
+
await assert.shouldNotPageHaveTitle(title);
|
|
383
|
+
},
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
// Check if the page should not have a specific URL
|
|
387
|
+
Then("User expects the page url should not be {string}", async function (url) {
|
|
388
|
+
await assert.shouldNotPageHaveURL(url);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
Then("User is not on {string} page", async function (url) {
|
|
392
|
+
await assert.shouldNotPageHaveURL(url);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// Check if a response should not be OK
|
|
396
|
+
Then("The response should not be OK", async function (response) {
|
|
397
|
+
await assert.shouldNotResponseBeOK(response);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
// Check if a selector's value should be equal to the expected value
|
|
401
|
+
Then(
|
|
402
|
+
"User expects {string} should be {string} text",
|
|
403
|
+
async function (selector, expected) {
|
|
404
|
+
await assert.shouldBe(selector, expected);
|
|
405
|
+
},
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
// Check if a selector's value should be close to the expected value within a precision
|
|
409
|
+
Then(
|
|
410
|
+
"User expects {string} should be close to {float} with precision {int}",
|
|
411
|
+
async function (selector, expected, precision) {
|
|
412
|
+
await assert.shouldBeCloseTo(selector, expected, precision);
|
|
413
|
+
},
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
// Check if a selector's value should be defined
|
|
417
|
+
Then("User expects {string} should be defined", async function (selector) {
|
|
418
|
+
await assert.shouldBeDefined(selector);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// Check if a selector's text content should be falsy
|
|
422
|
+
Then("User expects {string} should be falsy", async function (selector) {
|
|
423
|
+
await assert.shouldBeFalsy(selector);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// Check if a selector's value should be greater than the expected value
|
|
427
|
+
Then(
|
|
428
|
+
"User expects {string} should be greater than {float}",
|
|
429
|
+
async function (selector, expected) {
|
|
430
|
+
await assert.shouldBeGreaterThan(selector, expected);
|
|
431
|
+
},
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
// Check if a selector's value should be greater than or equal to the expected value
|
|
435
|
+
Then(
|
|
436
|
+
"User expects {string} should be greater than or equal to {float}",
|
|
437
|
+
async function (selector, expected) {
|
|
438
|
+
await assert.shouldBeGreaterThanOrEqual(selector, expected);
|
|
439
|
+
},
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
// Check if a selector's value should be an instance of a specific constructor
|
|
443
|
+
Then(
|
|
444
|
+
"User expects {string} should be an instance of {string}",
|
|
445
|
+
async function (selector, constructor) {
|
|
446
|
+
await assert.shouldBeInstanceOf(selector, constructor);
|
|
447
|
+
},
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
// Check if a selector's value should be less than the expected value
|
|
451
|
+
Then(
|
|
452
|
+
"User expects {string} should be less than {float}",
|
|
453
|
+
async function (selector, expected) {
|
|
454
|
+
await assert.shouldBeLessThan(selector, expected);
|
|
455
|
+
},
|
|
456
|
+
);
|
|
457
|
+
|
|
458
|
+
// Check if a selector's value should be less than or equal to the expected value
|
|
459
|
+
Then(
|
|
460
|
+
"User expects {string} should be less than or equal to {float}",
|
|
461
|
+
async function (selector, expected) {
|
|
462
|
+
await assert.shouldBeLessThanOrEqual(selector, expected);
|
|
463
|
+
},
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
// Check if a selector's value should be NaN
|
|
467
|
+
Then("User expects {string} should be NaN", async function (selector) {
|
|
468
|
+
await assert.shouldBeNaN(selector);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// Check if a selector's value should be null
|
|
472
|
+
Then("User expects {string} should be null", async function (selector) {
|
|
473
|
+
await assert.shouldBeNull(selector);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// Check if a selector's value should be truthy
|
|
477
|
+
Then("User expects {string} should be truthy", async function (selector) {
|
|
478
|
+
await assert.shouldBeTruthy(selector);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// Check if a selector's value should be undefined
|
|
482
|
+
Then("User expects {string} should be undefined", async function (selector) {
|
|
483
|
+
await assert.shouldBeUndefined(selector);
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// Check if a selector's value should contain a specific substring
|
|
487
|
+
Then(
|
|
488
|
+
"User expects {string} should have {string} substring",
|
|
489
|
+
async function (selector, substring) {
|
|
490
|
+
await assert.shouldContain(selector, substring);
|
|
491
|
+
},
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
// Check if a selector's value should contain an equal value
|
|
495
|
+
Then(
|
|
496
|
+
"User expects {string} should contain equal {string}",
|
|
497
|
+
async function (selector, expected) {
|
|
498
|
+
await assert.shouldContainEqual(selector, expected);
|
|
499
|
+
},
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
// Check if a selector's value should equal the expected value
|
|
503
|
+
Then(
|
|
504
|
+
"User expects {string} should equal {int}",
|
|
505
|
+
async function (selector, expected) {
|
|
506
|
+
await assert.shouldEqual(selector, expected);
|
|
507
|
+
},
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
// Check if a selector's text content should have a specific length
|
|
511
|
+
Then(
|
|
512
|
+
"User expects length of {string} should be {int}",
|
|
513
|
+
async function (selector, length) {
|
|
514
|
+
await assert.shouldHaveLength(selector, length);
|
|
515
|
+
},
|
|
516
|
+
);
|
|
517
|
+
|
|
518
|
+
// Check if a selector's text content should have a specific property
|
|
519
|
+
Then(
|
|
520
|
+
"User expects {string} should have {string} property",
|
|
521
|
+
async function (selector, property) {
|
|
522
|
+
await assert.shouldHaveProperty(selector, property);
|
|
523
|
+
},
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
// Check if a selector's text content should match a specific regex
|
|
527
|
+
Then(
|
|
528
|
+
"User expects {string} should match {string} regex",
|
|
529
|
+
async function (selector, regex) {
|
|
530
|
+
await assert.shouldMatch(selector, new RegExp(regex));
|
|
531
|
+
},
|
|
532
|
+
);
|
|
533
|
+
|
|
534
|
+
// Check if a selector's text content should match a specific object
|
|
535
|
+
Then(
|
|
536
|
+
"User expects {string} should match {string} object",
|
|
537
|
+
async function (selector, object) {
|
|
538
|
+
await assert.shouldMatchObject(selector, JSON.parse(object));
|
|
539
|
+
},
|
|
540
|
+
);
|
|
541
|
+
|
|
542
|
+
// Check if a selector's text content should strictly equal the expected value
|
|
543
|
+
Then(
|
|
544
|
+
"User expects {string} should strictly equal {string}",
|
|
545
|
+
async function (selector, expected) {
|
|
546
|
+
await assert.shouldStrictEqual(selector, expected);
|
|
547
|
+
},
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
// Check if a async function should throw an error
|
|
551
|
+
Then("The async function should throw", async function (fn) {
|
|
552
|
+
await assert.shouldThrow(fn);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
// Check if the text content of a selector should be an instance of a specific constructor
|
|
556
|
+
Then(
|
|
557
|
+
"User expects {string} should be any instance of {string}",
|
|
558
|
+
async function (selector, constructor) {
|
|
559
|
+
await assert.shouldAny(selector, constructor);
|
|
560
|
+
},
|
|
561
|
+
);
|
|
562
|
+
|
|
563
|
+
// Check if the text content of a selector may be anything (truthy)
|
|
564
|
+
Then("User expects {string} may be anything", async function (selector) {
|
|
565
|
+
await assert.shouldAnything(selector);
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// Check if the text content of a selector should contain any of the specified elements in an array
|
|
569
|
+
Then(
|
|
570
|
+
"User expects {string} should contain {string} array elements",
|
|
571
|
+
async function (selector, elements) {
|
|
572
|
+
const parsedElements = elements.split(",");
|
|
573
|
+
await assert.shouldArrayContaining(selector, parsedElements);
|
|
574
|
+
},
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
// Check if the text content of a selector should be close to the expected value within a precision
|
|
578
|
+
Then(
|
|
579
|
+
"User expects {string} should be close to {float} with precision {int}",
|
|
580
|
+
async function (selector, expected, precision) {
|
|
581
|
+
await assert.shouldCloseTo(selector, expected, precision);
|
|
582
|
+
},
|
|
583
|
+
);
|
|
584
|
+
|
|
585
|
+
// Check if the text content of a selector should contain the specified properties in an object
|
|
586
|
+
Then(
|
|
587
|
+
"User expects {string} should contain {string} object properties",
|
|
588
|
+
async function (selector, properties) {
|
|
589
|
+
const parsedProperties = properties.split(",");
|
|
590
|
+
await assert.shouldObjectContaining(selector, parsedProperties);
|
|
591
|
+
},
|
|
592
|
+
);
|
|
593
|
+
|
|
594
|
+
// Check if the text content of a selector should contain a specific substring
|
|
595
|
+
Then(
|
|
596
|
+
"User expects {string} should have {string} substring",
|
|
597
|
+
async function (selector, substring) {
|
|
598
|
+
await assert.shouldStringContaining(selector, substring);
|
|
599
|
+
},
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
// Check if the text content of a selector should match a specific regex
|
|
603
|
+
Then(
|
|
604
|
+
"User expects {string} should match {string} regex",
|
|
605
|
+
async function (selector, regex) {
|
|
606
|
+
await assert.shouldStringMatching(selector, new RegExp(regex));
|
|
607
|
+
},
|
|
608
|
+
);
|
|
609
|
+
|
|
610
|
+
// Check if a selector's text content should not be equal to the expected value
|
|
611
|
+
Then(
|
|
612
|
+
"User expects {string} should not be {string} text",
|
|
613
|
+
async function (selector, expected) {
|
|
614
|
+
await assert.shouldNotBe(selector, expected);
|
|
615
|
+
},
|
|
616
|
+
);
|
|
617
|
+
|
|
618
|
+
// Check if a selector's text content should not be close to the expected value within a precision
|
|
619
|
+
Then(
|
|
620
|
+
"User expects {string} should not be close to {float} with precision {int}",
|
|
621
|
+
async function (selector, expected, precision) {
|
|
622
|
+
await assert.shouldNotBeCloseTo(selector, expected, precision);
|
|
623
|
+
},
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
// Check if a selector's text content should not be defined
|
|
627
|
+
Then("User expects {string} should not be defined", async function (selector) {
|
|
628
|
+
await assert.shouldNotBeDefined(selector);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
// Check if a selector's text content should not be falsy
|
|
632
|
+
Then("User expects {string} should not be falsy", async function (selector) {
|
|
633
|
+
await assert.shouldNotBeFalsy(selector);
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
// Check if a selector's text content should not be greater than the expected value
|
|
637
|
+
Then(
|
|
638
|
+
"User expects {string} should not be greater than {float}",
|
|
639
|
+
async function (selector, expected) {
|
|
640
|
+
await assert.shouldNotBeGreaterThan(selector, expected);
|
|
641
|
+
},
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
// Check if a selector's text content should not be greater than or equal to the expected value
|
|
645
|
+
Then(
|
|
646
|
+
"User expects {string} should not be greater than or equal to {float}",
|
|
647
|
+
async function (selector, expected) {
|
|
648
|
+
await assert.shouldNotBeGreaterThanOrEqual(selector, expected);
|
|
649
|
+
},
|
|
650
|
+
);
|
|
651
|
+
|
|
652
|
+
// Check if a selector's text content should not be an instance of a specific constructor
|
|
653
|
+
Then(
|
|
654
|
+
"User expects {string} should not be an instance of {string}",
|
|
655
|
+
async function (selector, constructor) {
|
|
656
|
+
await assert.shouldNotBeInstanceOf(selector, constructor);
|
|
657
|
+
},
|
|
658
|
+
);
|
|
659
|
+
|
|
660
|
+
// Check if a selector's text content should not be less than the expected value
|
|
661
|
+
Then(
|
|
662
|
+
"User expects {string} should not be less than {float}",
|
|
663
|
+
async function (selector, expected) {
|
|
664
|
+
await assert.shouldNotBeLessThan(selector, expected);
|
|
665
|
+
},
|
|
666
|
+
);
|
|
667
|
+
|
|
668
|
+
// Check if a selector's text content should not be less than or equal to the expected value
|
|
669
|
+
Then(
|
|
670
|
+
"User expects {string} should not be less than or equal to {float}",
|
|
671
|
+
async function (selector, expected) {
|
|
672
|
+
await assert.shouldNotBeLessThanOrEqual(selector, expected);
|
|
673
|
+
},
|
|
674
|
+
);
|
|
675
|
+
|
|
676
|
+
// Check if a selector's text content should not be NaN
|
|
677
|
+
Then("User expects {string} should not be NaN", async function (selector) {
|
|
678
|
+
await assert.shouldNotBeNaN(selector);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
// Check if a selector's text content should not be null
|
|
682
|
+
Then("User expects {string} should not be null", async function (selector) {
|
|
683
|
+
await assert.shouldNotBeNull(selector);
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
// Check if a selector's text content should not be truthy
|
|
687
|
+
Then("User expects {string} should not be truthy", async function (selector) {
|
|
688
|
+
await assert.shouldNotBeTruthy(selector);
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
// Check if a selector's text content should not be undefined
|
|
692
|
+
Then(
|
|
693
|
+
"User expects {string} should not be undefined",
|
|
694
|
+
async function (selector) {
|
|
695
|
+
await assert.shouldNotBeUndefined(selector);
|
|
696
|
+
},
|
|
697
|
+
);
|
|
698
|
+
|
|
699
|
+
// Check if a selector's text content should not contain a specific substring
|
|
700
|
+
Then(
|
|
701
|
+
"User expects {string} should not have {string} substring",
|
|
702
|
+
async function (selector, substring) {
|
|
703
|
+
await assert.shouldNotContain(selector, substring);
|
|
704
|
+
},
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
// Check if a selector's text content should not contain an equal value
|
|
708
|
+
Then(
|
|
709
|
+
"User expects {string} should not contain equal {string}",
|
|
710
|
+
async function (selector, expected) {
|
|
711
|
+
await assert.shouldNotContainEqual(selector, expected);
|
|
712
|
+
},
|
|
713
|
+
);
|
|
714
|
+
|
|
715
|
+
// Check if a selector's text content should not equal the expected value
|
|
716
|
+
Then(
|
|
717
|
+
"User expects {string} should not equal {string}",
|
|
718
|
+
async function (selector, expected) {
|
|
719
|
+
await assert.shouldNotEqual(selector, expected);
|
|
720
|
+
},
|
|
721
|
+
);
|
|
722
|
+
|
|
723
|
+
// Check if a selector's text content should not have a specific length
|
|
724
|
+
Then(
|
|
725
|
+
"User expects length of {string} should not be {int} ",
|
|
726
|
+
async function (selector, length) {
|
|
727
|
+
await assert.shouldNotHaveLength(selector, length);
|
|
728
|
+
},
|
|
729
|
+
);
|
|
730
|
+
|
|
731
|
+
// Check if a selector's text content should not have a specific property
|
|
732
|
+
Then(
|
|
733
|
+
"User expects {string} should not have {string} property",
|
|
734
|
+
async function (selector, property) {
|
|
735
|
+
await assert.shouldNotHaveProperty(selector, property);
|
|
736
|
+
},
|
|
737
|
+
);
|
|
738
|
+
|
|
739
|
+
// Check if a selector's text content should not match a specific regex
|
|
740
|
+
Then(
|
|
741
|
+
"User expects {string} should not match {string} regex",
|
|
742
|
+
async function (selector, regex) {
|
|
743
|
+
await assert.shouldNotMatch(selector, new RegExp(regex));
|
|
744
|
+
},
|
|
745
|
+
);
|
|
746
|
+
|
|
747
|
+
// Check if a selector's text content should not match a specific object
|
|
748
|
+
Then(
|
|
749
|
+
"User expects {string} should not match {string} object",
|
|
750
|
+
async function (selector, object) {
|
|
751
|
+
await assert.shouldNotMatchObject(selector, JSON.parse(object));
|
|
752
|
+
},
|
|
753
|
+
);
|
|
754
|
+
|
|
755
|
+
// Check if a async function should not throw an error
|
|
756
|
+
Then("The async function should not throw", async function (fn) {
|
|
757
|
+
await assert.shouldNotThrow(fn);
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
// Check if a selector's text content should not be any instance of a specific constructor
|
|
761
|
+
Then(
|
|
762
|
+
"User expects {string} should not be any instance of {string}",
|
|
763
|
+
async function (selector, constructor) {
|
|
764
|
+
await assert.shouldNotAny(selector, constructor);
|
|
765
|
+
},
|
|
766
|
+
);
|
|
767
|
+
|
|
768
|
+
// Check if a selector's text content may not be anything (falsy)
|
|
769
|
+
Then("User expects {string} may not be anything", async function (selector) {
|
|
770
|
+
await assert.shouldNotAnything(selector);
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
// Check if a selector's text content should not contain any of the specified elements in an array
|
|
774
|
+
Then(
|
|
775
|
+
"User expects {string} should not contain {string} array elements",
|
|
776
|
+
async function (selector, elements) {
|
|
777
|
+
const parsedElements = elements.split(",");
|
|
778
|
+
await assert.shouldNotArrayContaining(selector, parsedElements);
|
|
779
|
+
},
|
|
780
|
+
);
|
|
781
|
+
|
|
782
|
+
// Check if a selector's text content should not be close to the expected value within a precision
|
|
783
|
+
Then(
|
|
784
|
+
"User expects {string} should not be close to {float} with precision {int}",
|
|
785
|
+
async function (selector, expected, precision) {
|
|
786
|
+
await assert.shouldNotCloseTo(selector, expected, precision);
|
|
787
|
+
},
|
|
788
|
+
);
|
|
789
|
+
|
|
790
|
+
// Check if a selector's text content should not contain the specified properties in an object
|
|
791
|
+
Then(
|
|
792
|
+
"User expects {string} should not contain {string} object properties",
|
|
793
|
+
async function (selector, properties) {
|
|
794
|
+
const parsedProperties = JSON.parse(properties);
|
|
795
|
+
await assert.shouldNotObjectContaining(selector, parsedProperties);
|
|
796
|
+
},
|
|
797
|
+
);
|
|
798
|
+
|
|
799
|
+
// Check if a selector's text content should not contain a specific substring
|
|
800
|
+
Then(
|
|
801
|
+
"User expects {string} should not contain {string} substring",
|
|
802
|
+
async function (selector, substring) {
|
|
803
|
+
await assert.shouldNotStringContaining(selector, substring);
|
|
804
|
+
},
|
|
805
|
+
);
|
|
806
|
+
|
|
807
|
+
// Check if a selector's text content should not match a specific regex
|
|
808
|
+
Then(
|
|
809
|
+
"User expects {string} should not match {string} regex",
|
|
810
|
+
async function (selector, regex) {
|
|
811
|
+
await assert.shouldNotStringMatching(selector, new RegExp(regex));
|
|
812
|
+
},
|
|
813
|
+
);
|
|
814
|
+
|
|
815
|
+
Then("User expects should have {int} {string}", async (count, elements) => {
|
|
816
|
+
const elementCount = await frame.count(elements);
|
|
817
|
+
expect(elementCount).toEqual(count);
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
Then(
|
|
821
|
+
"User expects that response has {string} field with {string} value",
|
|
822
|
+
async (field, value) => {
|
|
823
|
+
extractVarsFromResponse(context.response["Response Body"], field);
|
|
824
|
+
const varToString = JSON.stringify(context.vars[field]);
|
|
825
|
+
expect(varToString).toBe(value);
|
|
826
|
+
},
|
|
827
|
+
);
|
|
828
|
+
|
|
829
|
+
Then('User expects that {string} should match {string}', async (value1, value2) => {
|
|
830
|
+
await expect(resolveVariable(value1)).toBe(value2)
|
|
831
|
+
})
|
|
832
|
+
|
|
833
|
+
Then(
|
|
834
|
+
"User expects that response body should match {string} schema",
|
|
835
|
+
async function (expectedSchema) {
|
|
836
|
+
if(expectedSchema !="" ){
|
|
837
|
+
const schema = await selector(expectedSchema);
|
|
838
|
+
const ajv = await new Ajv();
|
|
839
|
+
const validate = await ajv.compile(schema);
|
|
840
|
+
const responseBody = await context.response["Response Body"];
|
|
841
|
+
const valid = await validate(responseBody);
|
|
842
|
+
await expect(valid).toBe(true);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
Then(
|
|
849
|
+
"User expects that request should have {int} status code",
|
|
850
|
+
async function (expectedStatusCode) {
|
|
851
|
+
const actualStatusCode = await context.response.Response.status();
|
|
852
|
+
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
853
|
+
}
|
|
854
|
+
);
|
|
855
|
+
|
|
856
|
+
Then(
|
|
857
|
+
"User expects that response should have {int} status code",
|
|
858
|
+
async function (expectedStatusCode) {
|
|
859
|
+
const actualStatusCode = await context.response.Response.status();
|
|
860
|
+
expect(actualStatusCode).toBe(expectedStatusCode);
|
|
861
|
+
}
|
|
862
862
|
);
|