@qavajs/cypress 2.6.0 → 2.8.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/lib/pageObjects.js +64 -24
- package/lib/setup.js +4 -3
- package/package.json +6 -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.8.0]
|
|
14
|
+
- :rocket: improved memory and page object logging
|
|
15
|
+
|
|
16
|
+
## [2.7.0]
|
|
17
|
+
- :rocket: added logic to display resolved selector chain
|
|
18
|
+
|
|
13
19
|
## [2.6.0]
|
|
14
20
|
- :rocket: added `I save value of...` step
|
|
15
21
|
|
package/lib/pageObjects.js
CHANGED
|
@@ -22,16 +22,22 @@ export const locator = function locator(selector) {
|
|
|
22
22
|
return new Selector(selector);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
locator.template = function(selector) {
|
|
25
|
+
locator.template = function (selector) {
|
|
26
26
|
return new Selector(selector, 'template');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
locator.native = function(selector) {
|
|
29
|
+
locator.native = function (selector) {
|
|
30
30
|
return new Selector(selector, 'native');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
locator.as = function (component) {
|
|
34
|
+
const selector = new Selector(null);
|
|
35
|
+
selector.component = component;
|
|
36
|
+
return selector;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
export class ChainItem {
|
|
34
|
-
constructor({
|
|
40
|
+
constructor({alias, argument, selector, type}) {
|
|
35
41
|
this.alias = alias;
|
|
36
42
|
this.argument = argument;
|
|
37
43
|
this.selector = selector;
|
|
@@ -67,26 +73,60 @@ export function query(root, path) {
|
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
export function element(path) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
return cy.then(() => {
|
|
77
|
+
const chain = query(this.pageObject, path);
|
|
78
|
+
let current = this.cy;
|
|
79
|
+
let method = 'get';
|
|
80
|
+
let logChain = `cy`;
|
|
81
|
+
|
|
82
|
+
const applySelector = (selector) => {
|
|
83
|
+
if (!selector) return;
|
|
84
|
+
logChain += `.${method}('${selector}')`;
|
|
85
|
+
current = current[method](selector);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const applyNative = (item) => {
|
|
89
|
+
logChain += `.native(${item.selector.toString()})`;
|
|
90
|
+
current = item.selector({
|
|
91
|
+
parent: current,
|
|
92
|
+
cy: this.cy,
|
|
93
|
+
argument: item.argument
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
for (const item of chain) {
|
|
98
|
+
switch (item.type) {
|
|
99
|
+
case 'simple': {
|
|
100
|
+
applySelector(item.selector);
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
case 'template': {
|
|
104
|
+
const selector = item.selector(item.argument);
|
|
105
|
+
applySelector(selector);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
case 'native': {
|
|
109
|
+
applyNative(item);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
throw new Error(`Unsupported selector type '${item.type}' for alias '${item.alias}'`);
|
|
114
|
+
}
|
|
115
|
+
method = item.selector ? 'find' : 'get';
|
|
88
116
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
117
|
+
Cypress.log({
|
|
118
|
+
displayName: `${path} →`,
|
|
119
|
+
message: logChain,
|
|
120
|
+
type: 'parent',
|
|
121
|
+
consoleProps: () => {
|
|
122
|
+
return {
|
|
123
|
+
Key: path,
|
|
124
|
+
Element: logChain,
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
alias: path,
|
|
128
|
+
aliasType: 'dom'
|
|
129
|
+
});
|
|
130
|
+
return current;
|
|
131
|
+
});
|
|
92
132
|
}
|
package/lib/setup.js
CHANGED
|
@@ -5,18 +5,19 @@ import {element} from './pageObjects';
|
|
|
5
5
|
const logger = {
|
|
6
6
|
log: (value) => {
|
|
7
7
|
const [displayName, divider, message] = value.split(/\s(->|<-)\s/);
|
|
8
|
+
const displayedDivider = divider === '->' ? '→' : '←';
|
|
8
9
|
cy.then(() => {
|
|
9
10
|
Cypress.log({
|
|
10
|
-
displayName: `${displayName} ${
|
|
11
|
+
displayName: `${displayName} ${displayedDivider}`,
|
|
11
12
|
message,
|
|
12
|
-
|
|
13
|
+
alias: displayName,
|
|
13
14
|
consoleProps: () => {
|
|
14
15
|
return {
|
|
15
16
|
Key: displayName,
|
|
16
17
|
Value: message,
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
})
|
|
20
|
+
});
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qavajs/cypress",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "qavajs for cypress runner",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"debug": "cypress open --config-file test-e2e/cypress.config.js",
|
|
8
|
-
"
|
|
8
|
+
"debug:it": "MODE=it cypress open --config-file test-e2e/cypress.config.js",
|
|
9
|
+
"test": "cypress run --config-file test-e2e/cypress.config.js",
|
|
10
|
+
"test:it": "MODE=it cypress run --config-file test-e2e/cypress.config.js"
|
|
9
11
|
},
|
|
10
12
|
"keywords": [
|
|
11
13
|
"QA",
|
|
@@ -27,8 +29,8 @@
|
|
|
27
29
|
"author": "Alexandr Galichenko",
|
|
28
30
|
"license": "MIT",
|
|
29
31
|
"devDependencies": {
|
|
30
|
-
"@qavajs/cypress-runner-adapter": "^1.
|
|
32
|
+
"@qavajs/cypress-runner-adapter": "^1.8.0",
|
|
31
33
|
"@qavajs/memory": "^1.10.3",
|
|
32
|
-
"cypress": "^15.
|
|
34
|
+
"cypress": "^15.11.0"
|
|
33
35
|
}
|
|
34
36
|
}
|