@qavajs/cypress 2.2.0 → 2.3.0
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/CHANGELOG.md +6 -0
- package/README.md +1 -2
- package/lib/actions.js +2 -35
- package/lib/pageObjects.js +1 -2
- package/lib/setup.js +14 -12
- package/lib/storage.js +0 -1
- package/lib/validation.js +5 -2
- package/lib/valueValidation.js +69 -51
- package/package.json +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
10
10
|
:pencil: - chore
|
|
11
11
|
:microscope: - experimental
|
|
12
12
|
|
|
13
|
+
## [2.3.0]
|
|
14
|
+
- :rocket: added `into` preposition to type and type chars steps
|
|
15
|
+
- :x: removed iframe steps
|
|
16
|
+
- :beetle: - fixed alert steps
|
|
17
|
+
- :beetle: - fixed desynchronization in validation steps
|
|
18
|
+
|
|
13
19
|
## [2.2.0]
|
|
14
20
|
- :rocket: added `to satisfy` validation to verify user-defined expectation provided as predicate
|
|
15
21
|
```Gherkin
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ qavajs implementation for cypress runner
|
|
|
3
3
|
|
|
4
4
|
## Installation
|
|
5
5
|
|
|
6
|
-
```
|
|
6
|
+
```bash
|
|
7
7
|
npm install @qavajs/cypress @qavajs/cypress-runner-adapter @qavajs/memory
|
|
8
8
|
```
|
|
9
9
|
|
|
@@ -45,7 +45,6 @@ Install dependencies
|
|
|
45
45
|
npm install
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
|
|
49
48
|
Execute tests
|
|
50
49
|
```
|
|
51
50
|
npm run test
|
package/lib/actions.js
CHANGED
|
@@ -15,8 +15,9 @@ When('I open {value} url', function (url) {
|
|
|
15
15
|
* @param {string} alias - element to type
|
|
16
16
|
* @param {string} value - value to type
|
|
17
17
|
* @example I type 'wikipedia' to 'Google Input'
|
|
18
|
+
* @example I type 'wikipedia' into 'Google Input'
|
|
18
19
|
*/
|
|
19
|
-
When('I type {value} to {locator}', function (type, locator) {
|
|
20
|
+
When('I type {value} (in)to {locator}', function (type, locator) {
|
|
20
21
|
locator.type(type.value());
|
|
21
22
|
});
|
|
22
23
|
//
|
|
@@ -65,40 +66,6 @@ When('I clear {locator}', function (locator) {
|
|
|
65
66
|
locator.clear();
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
/**
|
|
69
|
-
* Switch to parent frame
|
|
70
|
-
* @example I switch to parent frame
|
|
71
|
-
*/
|
|
72
|
-
When('I switch to parent frame', function () {
|
|
73
|
-
this.cy = cy;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Switch to frame by index
|
|
78
|
-
* @param {number} index - index to switch
|
|
79
|
-
* @example I switch to 2 frame
|
|
80
|
-
*/
|
|
81
|
-
When('I switch to {int} frame', function (index) {
|
|
82
|
-
const root = this.cy === cy ? this.cy.get('iframe') : this.cy.find('iframe');
|
|
83
|
-
this.cy = root
|
|
84
|
-
.eq(index - 1)
|
|
85
|
-
.then((iframe) => iframe.contents())
|
|
86
|
-
.should('exist')
|
|
87
|
-
.find('body');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Switch to frame by alias
|
|
92
|
-
* @param {string} index - alias to switch
|
|
93
|
-
* @example I switch to 'IFrame' frame
|
|
94
|
-
*/
|
|
95
|
-
When('I switch to {locator} frame', function (frame) {
|
|
96
|
-
this.cy = frame
|
|
97
|
-
.then((iframe) => iframe.contents())
|
|
98
|
-
.should('exist')
|
|
99
|
-
.find('body');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
69
|
/**
|
|
103
70
|
* Refresh current page
|
|
104
71
|
* @example I r efresh page
|
package/lib/pageObjects.js
CHANGED
package/lib/setup.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import memory from '@qavajs/memory';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {setWorldConstructor} from '@qavajs/cypress-runner-adapter';
|
|
3
|
+
import {element} from './pageObjects';
|
|
4
4
|
|
|
5
5
|
const logger = {
|
|
6
6
|
log: (value) => {
|
|
7
7
|
const [displayName, divider, message] = value.split(/\s(->|<-)\s/);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
cy.then(() => {
|
|
9
|
+
Cypress.log({
|
|
10
|
+
displayName: `${displayName} ${divider}`,
|
|
11
|
+
message,
|
|
12
|
+
type: 'parent',
|
|
13
|
+
consoleProps: () => {
|
|
14
|
+
return {
|
|
15
|
+
Key: displayName,
|
|
16
|
+
Value: message,
|
|
17
|
+
}
|
|
16
18
|
}
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
+
})
|
|
20
|
+
});
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
|
package/lib/storage.js
CHANGED
|
@@ -40,7 +40,6 @@ When('I set {value} {word} storage value as {value}', function (storageKey, stor
|
|
|
40
40
|
const resolvedValue = value.value();
|
|
41
41
|
const storageKeyName = storageKey.value();
|
|
42
42
|
cy.window().then((win) => {
|
|
43
|
-
console.log(win)
|
|
44
43
|
win[storageType + 'Storage'].setItem(storageKeyName, resolvedValue);
|
|
45
44
|
});
|
|
46
45
|
});
|
package/lib/validation.js
CHANGED
|
@@ -230,9 +230,12 @@ Then(
|
|
|
230
230
|
resolve(alertText)
|
|
231
231
|
});
|
|
232
232
|
});
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
cy.then(() => {
|
|
234
|
+
return alertHandler.then(alertText => {
|
|
235
|
+
validation(alertText, expectedValue.value())
|
|
236
|
+
});
|
|
235
237
|
})
|
|
238
|
+
|
|
236
239
|
}
|
|
237
240
|
);
|
|
238
241
|
|
package/lib/valueValidation.js
CHANGED
|
@@ -14,9 +14,11 @@ import { getValidation } from './valueExpect';
|
|
|
14
14
|
Then(
|
|
15
15
|
'I expect {value} {validation} {value}',
|
|
16
16
|
function (value1, validation, value2) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
cy.then(() => {
|
|
18
|
+
const val1 = value1.value();
|
|
19
|
+
const val2 = value2.value();
|
|
20
|
+
validation(val1, val2);
|
|
21
|
+
});
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -30,20 +32,22 @@ Then(
|
|
|
30
32
|
Then(
|
|
31
33
|
'I expect at least {int} element(s) in {value} array {validation} {value}',
|
|
32
34
|
function (expectedNumber, arr, validation, expectedValue) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
cy.then(() => {
|
|
36
|
+
const array = arr.value();
|
|
37
|
+
const val = expectedValue.value();
|
|
38
|
+
const failCounter = { fail: 0, pass: 0 };
|
|
39
|
+
for (const value of array) {
|
|
40
|
+
try {
|
|
41
|
+
validation(value, val);
|
|
42
|
+
failCounter.pass++;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
failCounter.fail++;
|
|
45
|
+
}
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
+
if (failCounter.pass < expectedNumber) {
|
|
48
|
+
throw new Error(`Less than ${expectedNumber} pass ${validation} verification`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
47
51
|
}
|
|
48
52
|
);
|
|
49
53
|
|
|
@@ -58,11 +62,13 @@ Then(
|
|
|
58
62
|
Then(
|
|
59
63
|
'I expect every element in {value} array {validation} {value}',
|
|
60
64
|
function (arr, validation, expectedValue) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
cy.then(() => {
|
|
66
|
+
const array = arr.value();
|
|
67
|
+
const val = expectedValue.value();
|
|
68
|
+
for (const value of array) {
|
|
69
|
+
validation(value, val);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
66
72
|
}
|
|
67
73
|
);
|
|
68
74
|
|
|
@@ -77,14 +83,16 @@ Then(
|
|
|
77
83
|
Then(
|
|
78
84
|
'I expect {value} array to be sorted by {value}',
|
|
79
85
|
function (arr, comparator) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
cy.then(() => {
|
|
87
|
+
const array = arr.value();
|
|
88
|
+
if (!Array.isArray(array)) throw new Error(`'${arr}' is not an array`);
|
|
89
|
+
const comparatorFn = comparator.value();
|
|
90
|
+
if (typeof comparatorFn !== 'function') throw new Error(`'${comparator}' is not implemented`);
|
|
91
|
+
const arrayCopy = [...array];
|
|
92
|
+
arrayCopy.sort(comparatorFn);
|
|
93
|
+
const validation = getValidation('to deeply equal');
|
|
94
|
+
validation(array, arrayCopy);
|
|
95
|
+
});
|
|
88
96
|
}
|
|
89
97
|
);
|
|
90
98
|
|
|
@@ -102,9 +110,11 @@ Then(
|
|
|
102
110
|
Then(
|
|
103
111
|
'I expect {value} array {validation}:',
|
|
104
112
|
function (arr, validation, members) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
113
|
+
cy.then(() => {
|
|
114
|
+
const array = arr.value();
|
|
115
|
+
const membersArray = dataTable2Array(this, members);
|
|
116
|
+
validation(array, membersArray);
|
|
117
|
+
});
|
|
108
118
|
}
|
|
109
119
|
);
|
|
110
120
|
|
|
@@ -119,11 +129,13 @@ Then(
|
|
|
119
129
|
Then(
|
|
120
130
|
'I expect {value} {validation} at least one of {value}',
|
|
121
131
|
function (actual, validation, expected) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
cy.then(() => {
|
|
133
|
+
const actualValue = actual.value();
|
|
134
|
+
const expectedValues = expected.value();
|
|
135
|
+
if (!(expectedValues instanceof Array)) throw new Error(`'${expected}' parameter is not an array`);
|
|
136
|
+
const validate = (AR, ER) => validation(AR, ER);
|
|
137
|
+
validateAnyOf(actualValue, expectedValues, validate);
|
|
138
|
+
});
|
|
127
139
|
}
|
|
128
140
|
);
|
|
129
141
|
|
|
@@ -140,10 +152,12 @@ Then(
|
|
|
140
152
|
Then(
|
|
141
153
|
'I expect {value} {validation} at least one of:',
|
|
142
154
|
function (actual, valueExpect, expected) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
cy.then(() => {
|
|
156
|
+
const actualValue = actual.value();
|
|
157
|
+
const expectedValues = dataTable2Array(this, expected);
|
|
158
|
+
const validation = (AR, ER) => valueExpect(AR, ER, validation);
|
|
159
|
+
validateAnyOf(actualValue, expectedValues, validation);
|
|
160
|
+
});
|
|
147
161
|
}
|
|
148
162
|
);
|
|
149
163
|
|
|
@@ -158,11 +172,13 @@ Then(
|
|
|
158
172
|
Then(
|
|
159
173
|
'I expect {value} {validation} all of {value}',
|
|
160
174
|
function (actual, valueExpect, expected) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
cy.then(() => {
|
|
176
|
+
const actualValue = actual.value();
|
|
177
|
+
const expectedValues = expected.value();
|
|
178
|
+
if (!(expectedValues instanceof Array)) throw new Error(`'${expected}' parameter is not an array`);
|
|
179
|
+
const validation = (AR, ER) => valueExpect(AR, ER);
|
|
180
|
+
validateAllOf(actualValue, expectedValues, validation);
|
|
181
|
+
});
|
|
166
182
|
}
|
|
167
183
|
);
|
|
168
184
|
|
|
@@ -179,11 +195,13 @@ Then(
|
|
|
179
195
|
Then(
|
|
180
196
|
'I expect {value} {validation} all of:',
|
|
181
197
|
function (actual, valueExpect, expected) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
198
|
+
cy.then(() => {
|
|
199
|
+
const actualValue = actual.value();
|
|
200
|
+
const expectedValues = dataTable2Array(this, expected);
|
|
201
|
+
const validation = (AR, ER) => valueExpect(AR, ER);
|
|
202
|
+
validateAllOf(actualValue, expectedValues, validation);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
187
205
|
);
|
|
188
206
|
|
|
189
207
|
function validateAnyOf(AR, ERs, validation){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qavajs/cypress",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "qavajs for cypress runner",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,13 +9,18 @@
|
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"QA",
|
|
12
|
-
"
|
|
12
|
+
"testing",
|
|
13
|
+
"test-automation",
|
|
14
|
+
"cypress",
|
|
15
|
+
"qavajs",
|
|
16
|
+
"cucumber",
|
|
17
|
+
"cucumberjs"
|
|
13
18
|
],
|
|
14
19
|
"author": "Alexandr Galichenko",
|
|
15
20
|
"license": "MIT",
|
|
16
21
|
"devDependencies": {
|
|
17
|
-
"@qavajs/cypress-runner-adapter": "^1.
|
|
22
|
+
"@qavajs/cypress-runner-adapter": "^1.3.0",
|
|
18
23
|
"@qavajs/memory": "^1.10.2",
|
|
19
|
-
"cypress": "^15.
|
|
24
|
+
"cypress": "^15.3.0"
|
|
20
25
|
}
|
|
21
26
|
}
|