codeceptjs 3.7.0-beta.5 → 3.7.0-beta.7
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 +7 -7
- package/lib/effects.js +165 -70
- package/lib/helper/Appium.js +4 -6
- package/lib/helper/WebDriver.js +20 -7
- package/lib/pause.js +0 -3
- package/lib/plugin/retryTo.js +18 -126
- package/lib/plugin/tryTo.js +13 -111
- package/package.json +13 -13
- package/typings/promiseBasedTypes.d.ts +518 -24
- package/typings/types.d.ts +526 -24
- package/lib/step/section.js +0 -25
package/lib/plugin/tryTo.js
CHANGED
|
@@ -1,115 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
module.exports = function () {
|
|
2
|
+
console.log(`
|
|
3
|
+
Deprecated Warning: 'tryTo' has been moved to the effects module.
|
|
4
|
+
You should update your tests to use it as follows:
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Adds global `tryTo` function in which all failed steps won't fail a test but will return true/false.
|
|
12
|
-
*
|
|
13
|
-
* Enable this plugin in `codecept.conf.js` (enabled by default for new setups):
|
|
14
|
-
*
|
|
15
|
-
* ```js
|
|
16
|
-
* plugins: {
|
|
17
|
-
* tryTo: {
|
|
18
|
-
* enabled: true
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
* Use it in your tests:
|
|
23
|
-
*
|
|
24
|
-
* ```js
|
|
25
|
-
* const result = await tryTo(() => I.see('Welcome'));
|
|
26
|
-
*
|
|
27
|
-
* // if text "Welcome" is on page, result => true
|
|
28
|
-
* // if text "Welcome" is not on page, result => false
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* Disables retryFailedStep plugin for steps inside a block;
|
|
32
|
-
*
|
|
33
|
-
* Use this plugin if:
|
|
34
|
-
*
|
|
35
|
-
* * you need to perform multiple assertions inside a test
|
|
36
|
-
* * there is A/B testing on a website you test
|
|
37
|
-
* * there is "Accept Cookie" banner which may surprisingly appear on a page.
|
|
38
|
-
*
|
|
39
|
-
* #### Usage
|
|
40
|
-
*
|
|
41
|
-
* #### Multiple Conditional Assertions
|
|
42
|
-
*
|
|
43
|
-
* ```js
|
|
44
|
-
*
|
|
45
|
-
* Add assert requires first:
|
|
46
|
-
* ```js
|
|
47
|
-
* const assert = require('assert');
|
|
48
|
-
* ```
|
|
49
|
-
* Then use the assertion:
|
|
50
|
-
* const result1 = await tryTo(() => I.see('Hello, user'));
|
|
51
|
-
* const result2 = await tryTo(() => I.seeElement('.welcome'));
|
|
52
|
-
* assert.ok(result1 && result2, 'Assertions were not succesful');
|
|
53
|
-
* ```
|
|
54
|
-
*
|
|
55
|
-
* ##### Optional click
|
|
56
|
-
*
|
|
57
|
-
* ```js
|
|
58
|
-
* I.amOnPage('/');
|
|
59
|
-
* tryTo(() => I.click('Agree', '.cookies'));
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* #### Configuration
|
|
63
|
-
*
|
|
64
|
-
* * `registerGlobal` - to register `tryTo` function globally, true by default
|
|
65
|
-
*
|
|
66
|
-
* If `registerGlobal` is false you can use tryTo from the plugin:
|
|
67
|
-
*
|
|
68
|
-
* ```js
|
|
69
|
-
* const tryTo = codeceptjs.container.plugins('tryTo');
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
module.exports = function (config) {
|
|
74
|
-
config = Object.assign(defaultConfig, config)
|
|
6
|
+
\`\`\`javascript
|
|
7
|
+
const { tryTo } = require('codeceptjs/effects');
|
|
75
8
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
9
|
+
// Example: failed step won't fail a test but will return true/false
|
|
10
|
+
await tryTo(() => {
|
|
11
|
+
I.switchTo('#editor frame');
|
|
12
|
+
});
|
|
13
|
+
\`\`\`
|
|
81
14
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return recorder.add(
|
|
85
|
-
'tryTo',
|
|
86
|
-
() => {
|
|
87
|
-
recorder.session.start('tryTo')
|
|
88
|
-
process.env.TRY_TO = 'true'
|
|
89
|
-
callback()
|
|
90
|
-
recorder.add(() => {
|
|
91
|
-
result = true
|
|
92
|
-
recorder.session.restore('tryTo')
|
|
93
|
-
return result
|
|
94
|
-
})
|
|
95
|
-
recorder.session.catch(err => {
|
|
96
|
-
result = false
|
|
97
|
-
const msg = err.inspect ? err.inspect() : err.toString()
|
|
98
|
-
debug(`Unsuccessful try > ${msg}`)
|
|
99
|
-
recorder.session.restore('tryTo')
|
|
100
|
-
return result
|
|
101
|
-
})
|
|
102
|
-
return recorder.add(
|
|
103
|
-
'result',
|
|
104
|
-
() => {
|
|
105
|
-
process.env.TRY_TO = undefined
|
|
106
|
-
return result
|
|
107
|
-
},
|
|
108
|
-
true,
|
|
109
|
-
false,
|
|
110
|
-
)
|
|
111
|
-
},
|
|
112
|
-
false,
|
|
113
|
-
false,
|
|
114
|
-
)
|
|
15
|
+
For more details, refer to the documentation.
|
|
16
|
+
`)
|
|
115
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeceptjs",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.7",
|
|
4
4
|
"description": "Supercharged End 2 End Testing Framework for NodeJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acceptance",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"test:unit": "mocha test/unit --recursive --timeout 10000",
|
|
51
51
|
"test:runner": "mocha test/runner --recursive --timeout 10000",
|
|
52
52
|
"test": "npm run test:unit && npm run test:runner",
|
|
53
|
-
"test:appium-quick": "mocha test/helper/
|
|
54
|
-
"test:appium-other": "mocha test/helper/
|
|
55
|
-
"test:ios:appium-quick": "mocha test/helper/
|
|
56
|
-
"test:ios:appium-other": "mocha test/helper/
|
|
53
|
+
"test:appium-quick": "mocha test/helper/Appium_test.js --grep 'quick'",
|
|
54
|
+
"test:appium-other": "mocha test/helper/Appium_test.js --grep 'second'",
|
|
55
|
+
"test:ios:appium-quick": "mocha test/helper/Appium_ios_test.js --grep 'quick'",
|
|
56
|
+
"test:ios:appium-other": "mocha test/helper/Appium_ios_test.js --grep 'second'",
|
|
57
57
|
"test-app:start": "php -S 127.0.0.1:8000 -t test/data/app",
|
|
58
58
|
"test-app:stop": "kill -9 $(lsof -t -i:8000)",
|
|
59
59
|
"test:unit:webbapi:playwright": "mocha test/helper/Playwright_test.js",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"figures": "3.2.0",
|
|
95
95
|
"fn-args": "4.0.0",
|
|
96
96
|
"fs-extra": "11.2.0",
|
|
97
|
-
"glob": "
|
|
97
|
+
"glob": ">=9.0.0",
|
|
98
98
|
"fuse.js": "^7.0.0",
|
|
99
99
|
"html-minifier-terser": "7.2.0",
|
|
100
100
|
"inquirer": "6.5.2",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"promise-retry": "1.1.1",
|
|
114
114
|
"resq": "1.11.0",
|
|
115
115
|
"sprintf-js": "1.1.3",
|
|
116
|
-
"uuid": "11.0.
|
|
116
|
+
"uuid": "11.0.5"
|
|
117
117
|
},
|
|
118
118
|
"optionalDependencies": {
|
|
119
119
|
"@codeceptjs/detox-helper": "1.1.5"
|
|
@@ -124,13 +124,13 @@
|
|
|
124
124
|
"@codeceptjs/mock-request": "0.3.1",
|
|
125
125
|
"@eslint/eslintrc": "3.2.0",
|
|
126
126
|
"@eslint/js": "9.18.0",
|
|
127
|
-
"@faker-js/faker": "9.
|
|
127
|
+
"@faker-js/faker": "9.4.0",
|
|
128
128
|
"@pollyjs/adapter-puppeteer": "6.0.6",
|
|
129
129
|
"@pollyjs/core": "5.1.0",
|
|
130
130
|
"@types/chai": "4.3.19",
|
|
131
131
|
"@types/inquirer": "9.0.7",
|
|
132
|
-
"@types/node": "22.10.
|
|
133
|
-
"@wdio/sauce-service": "9.5.
|
|
132
|
+
"@types/node": "22.10.7",
|
|
133
|
+
"@wdio/sauce-service": "9.5.7",
|
|
134
134
|
"@wdio/selenium-standalone-service": "8.15.0",
|
|
135
135
|
"@wdio/utils": "9.5.0",
|
|
136
136
|
"@xmldom/xmldom": "0.9.6",
|
|
@@ -138,8 +138,8 @@
|
|
|
138
138
|
"chai-as-promised": "7.1.2",
|
|
139
139
|
"chai-subset": "1.6.0",
|
|
140
140
|
"documentation": "14.0.3",
|
|
141
|
-
"electron": "
|
|
142
|
-
"eslint": "^9.
|
|
141
|
+
"electron": "34.0.0",
|
|
142
|
+
"eslint": "^9.18.0",
|
|
143
143
|
"eslint-plugin-import": "2.31.0",
|
|
144
144
|
"eslint-plugin-mocha": "10.5.0",
|
|
145
145
|
"expect": "29.7.0",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"json-server": "0.17.4",
|
|
155
155
|
"playwright": "1.49.1",
|
|
156
156
|
"prettier": "^3.3.2",
|
|
157
|
-
"puppeteer": "
|
|
157
|
+
"puppeteer": "24.0.0",
|
|
158
158
|
"qrcode-terminal": "0.12.0",
|
|
159
159
|
"rosie": "2.1.1",
|
|
160
160
|
"runok": "0.9.3",
|