codeceptjs 3.7.0-beta.15 → 3.7.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/codecept.js +1 -1
- package/lib/command/check.js +3 -2
- package/lib/effects.js +7 -2
- package/lib/helper/Playwright.js +1 -1
- package/lib/helper/Puppeteer.js +1 -1
- package/lib/plugin/retryFailedStep.js +13 -14
- package/lib/recorder.js +1 -0
- package/lib/store.js +29 -5
- package/lib/within.js +2 -0
- package/package.json +1 -1
- package/typings/promiseBasedTypes.d.ts +24 -0
- package/typings/types.d.ts +45 -1
package/bin/codecept.js
CHANGED
|
@@ -62,7 +62,7 @@ program
|
|
|
62
62
|
.command('check')
|
|
63
63
|
.option(commandFlags.config.flag, commandFlags.config.description)
|
|
64
64
|
.description('Checks configuration and environment before running tests')
|
|
65
|
-
.option('-t, --timeout [ms]', 'timeout for checks in ms,
|
|
65
|
+
.option('-t, --timeout [ms]', 'timeout for checks in ms, 50000 by default')
|
|
66
66
|
.action(errorHandler(require('../lib/command/check')))
|
|
67
67
|
|
|
68
68
|
program
|
package/lib/command/check.js
CHANGED
|
@@ -87,9 +87,9 @@ module.exports = async function (options) {
|
|
|
87
87
|
|
|
88
88
|
if (config?.ai?.request) {
|
|
89
89
|
checks.ai = true
|
|
90
|
-
printCheck('ai', checks['ai'], '
|
|
90
|
+
printCheck('ai', checks['ai'], 'Configuration is enabled, request function is set')
|
|
91
91
|
} else {
|
|
92
|
-
printCheck('ai', checks['ai'], '
|
|
92
|
+
printCheck('ai', checks['ai'], 'Disabled')
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
printCheck('tests', checks['tests'], `Total: ${numTests} tests`)
|
|
@@ -142,6 +142,7 @@ module.exports = async function (options) {
|
|
|
142
142
|
}
|
|
143
143
|
checks.setup = true
|
|
144
144
|
} catch (err) {
|
|
145
|
+
err.message = `${helper.constructor.name} helper failed: ${err.message}`
|
|
145
146
|
checks.setup = err
|
|
146
147
|
}
|
|
147
148
|
}
|
package/lib/effects.js
CHANGED
|
@@ -2,6 +2,7 @@ const recorder = require('./recorder')
|
|
|
2
2
|
const { debug } = require('./output')
|
|
3
3
|
const store = require('./store')
|
|
4
4
|
const event = require('./event')
|
|
5
|
+
const within = require('./within')
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* A utility function for CodeceptJS tests that acts as a soft assertion.
|
|
@@ -178,11 +179,14 @@ async function tryTo(callback) {
|
|
|
178
179
|
const sessionName = 'tryTo'
|
|
179
180
|
|
|
180
181
|
let result = false
|
|
182
|
+
let hasAutoRetriesEnabled = store.autoRetries
|
|
181
183
|
return recorder.add(
|
|
182
184
|
sessionName,
|
|
183
185
|
() => {
|
|
184
186
|
recorder.session.start(sessionName)
|
|
185
|
-
|
|
187
|
+
hasAutoRetriesEnabled = store.autoRetries
|
|
188
|
+
if (hasAutoRetriesEnabled) debug('Auto retries disabled inside tryTo effect')
|
|
189
|
+
store.autoRetries = false
|
|
186
190
|
callback()
|
|
187
191
|
recorder.add(() => {
|
|
188
192
|
result = true
|
|
@@ -199,7 +203,7 @@ async function tryTo(callback) {
|
|
|
199
203
|
return recorder.add(
|
|
200
204
|
'result',
|
|
201
205
|
() => {
|
|
202
|
-
store.
|
|
206
|
+
store.autoRetries = hasAutoRetriesEnabled
|
|
203
207
|
return result
|
|
204
208
|
},
|
|
205
209
|
true,
|
|
@@ -215,4 +219,5 @@ module.exports = {
|
|
|
215
219
|
hopeThat,
|
|
216
220
|
retryTo,
|
|
217
221
|
tryTo,
|
|
222
|
+
within,
|
|
218
223
|
}
|
package/lib/helper/Playwright.js
CHANGED
|
@@ -484,7 +484,7 @@ class Playwright extends Helper {
|
|
|
484
484
|
this.currentRunningTest = test
|
|
485
485
|
|
|
486
486
|
recorder.retry({
|
|
487
|
-
retries:
|
|
487
|
+
retries: test?.opts?.conditionalRetries || 3,
|
|
488
488
|
when: err => {
|
|
489
489
|
if (!err || typeof err.message !== 'string') {
|
|
490
490
|
return false
|
package/lib/helper/Puppeteer.js
CHANGED
|
@@ -312,7 +312,7 @@ class Puppeteer extends Helper {
|
|
|
312
312
|
this.sessionPages = {}
|
|
313
313
|
this.currentRunningTest = test
|
|
314
314
|
recorder.retry({
|
|
315
|
-
retries:
|
|
315
|
+
retries: test?.opts?.conditionalRetries || 3,
|
|
316
316
|
when: err => {
|
|
317
317
|
if (!err || typeof err.message !== 'string') {
|
|
318
318
|
return false
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const event = require('../event')
|
|
2
2
|
const recorder = require('../recorder')
|
|
3
|
-
const
|
|
4
|
-
const { log } = require('../output')
|
|
5
|
-
|
|
3
|
+
const store = require('../store')
|
|
6
4
|
const defaultConfig = {
|
|
7
5
|
retries: 3,
|
|
8
6
|
defaultIgnoredSteps: ['amOnPage', 'wait*', 'send*', 'execute*', 'run*', 'have*'],
|
|
@@ -70,9 +68,9 @@ const defaultConfig = {
|
|
|
70
68
|
* Use scenario configuration to disable plugin for a test
|
|
71
69
|
*
|
|
72
70
|
* ```js
|
|
73
|
-
* Scenario('scenario tite', () => {
|
|
71
|
+
* Scenario('scenario tite', { disableRetryFailedStep: true }, () => {
|
|
74
72
|
* // test goes here
|
|
75
|
-
* })
|
|
73
|
+
* })
|
|
76
74
|
* ```
|
|
77
75
|
*
|
|
78
76
|
*/
|
|
@@ -85,19 +83,14 @@ module.exports = config => {
|
|
|
85
83
|
|
|
86
84
|
const when = err => {
|
|
87
85
|
if (!enableRetry) return
|
|
88
|
-
const store = require('../store')
|
|
89
86
|
if (store.debugMode) return false
|
|
87
|
+
if (!store.autoRetries) return false
|
|
90
88
|
if (customWhen) return customWhen(err)
|
|
91
89
|
return true
|
|
92
90
|
}
|
|
93
91
|
config.when = when
|
|
94
92
|
|
|
95
93
|
event.dispatcher.on(event.step.started, step => {
|
|
96
|
-
if (process.env.TRY_TO === 'true') {
|
|
97
|
-
log('Info: RetryFailedStep plugin is disabled inside tryTo block')
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
|
|
101
94
|
// if a step is ignored - return
|
|
102
95
|
for (const ignored of config.ignoredSteps) {
|
|
103
96
|
if (step.name === ignored) return
|
|
@@ -113,9 +106,15 @@ module.exports = config => {
|
|
|
113
106
|
})
|
|
114
107
|
|
|
115
108
|
event.dispatcher.on(event.test.before, test => {
|
|
116
|
-
|
|
117
|
-
//
|
|
118
|
-
|
|
109
|
+
// pass disableRetryFailedStep is a preferred way to disable retries
|
|
110
|
+
// test.disableRetryFailedStep is used for backward compatibility
|
|
111
|
+
if (test.opts.disableRetryFailedStep || test.disableRetryFailedStep) {
|
|
112
|
+
store.autoRetries = false
|
|
113
|
+
return // disable retry when a test is not active
|
|
114
|
+
}
|
|
115
|
+
// this option is used to set the retries inside _before() block of helpers
|
|
116
|
+
store.autoRetries = true
|
|
117
|
+
test.opts.conditionalRetries = config.retries
|
|
119
118
|
recorder.retry(config)
|
|
120
119
|
})
|
|
121
120
|
}
|
package/lib/recorder.js
CHANGED
|
@@ -192,6 +192,7 @@ module.exports = {
|
|
|
192
192
|
.pop()
|
|
193
193
|
// no retries or unnamed tasks
|
|
194
194
|
debug(`${currentQueue()} Running | ${taskName} | Timeout: ${timeout || 'None'}`)
|
|
195
|
+
if (retryOpts) debug(`${currentQueue()} Retry opts`, JSON.stringify(retryOpts))
|
|
195
196
|
|
|
196
197
|
if (!retryOpts || !taskName || !retry) {
|
|
197
198
|
const [promise, timer] = getTimeoutPromise(timeout, taskName)
|
package/lib/store.js
CHANGED
|
@@ -3,17 +3,41 @@
|
|
|
3
3
|
* @namespace
|
|
4
4
|
*/
|
|
5
5
|
const store = {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* If we are in --debug mode
|
|
8
|
+
* @type {boolean}
|
|
9
|
+
*/
|
|
7
10
|
debugMode: false,
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Is timeouts enabled
|
|
14
|
+
* @type {boolean}
|
|
15
|
+
*/
|
|
9
16
|
timeouts: true,
|
|
10
|
-
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* If auto-retries are enabled by retryFailedStep plugin
|
|
20
|
+
* tryTo effect disables them
|
|
21
|
+
* @type {boolean}
|
|
22
|
+
*/
|
|
23
|
+
autoRetries: false,
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Tests are executed via dry-run
|
|
27
|
+
* @type {boolean}
|
|
28
|
+
*/
|
|
11
29
|
dryRun: false,
|
|
12
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* If we are in pause mode
|
|
32
|
+
* @type {boolean}
|
|
33
|
+
*/
|
|
13
34
|
onPause: false,
|
|
35
|
+
|
|
36
|
+
// current object states
|
|
37
|
+
|
|
14
38
|
/** @type {CodeceptJS.Test | null} */
|
|
15
39
|
currentTest: null,
|
|
16
|
-
/** @type {
|
|
40
|
+
/** @type {CodeceptJS.Step | null} */
|
|
17
41
|
currentStep: null,
|
|
18
42
|
/** @type {CodeceptJS.Suite | null} */
|
|
19
43
|
currentSuite: null,
|
package/lib/within.js
CHANGED
package/package.json
CHANGED
|
@@ -1759,6 +1759,10 @@ declare namespace CodeceptJS {
|
|
|
1759
1759
|
* @property [host = "0.0.0.0"] - Mock server host
|
|
1760
1760
|
* @property [httpsOpts] - key & cert values are the paths to .key and .crt files
|
|
1761
1761
|
*/
|
|
1762
|
+
// @ts-ignore
|
|
1763
|
+
// @ts-ignore
|
|
1764
|
+
// @ts-ignore
|
|
1765
|
+
// @ts-ignore
|
|
1762
1766
|
type MockServerConfig = {
|
|
1763
1767
|
port?: number;
|
|
1764
1768
|
host?: string;
|
|
@@ -1883,6 +1887,10 @@ declare namespace CodeceptJS {
|
|
|
1883
1887
|
*
|
|
1884
1888
|
* ## Methods
|
|
1885
1889
|
*/
|
|
1890
|
+
// @ts-ignore
|
|
1891
|
+
// @ts-ignore
|
|
1892
|
+
// @ts-ignore
|
|
1893
|
+
// @ts-ignore
|
|
1886
1894
|
class MockServer {
|
|
1887
1895
|
/**
|
|
1888
1896
|
* Start the mock server
|
|
@@ -2916,6 +2924,10 @@ declare namespace CodeceptJS {
|
|
|
2916
2924
|
* @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
|
|
2917
2925
|
* @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
|
|
2918
2926
|
*/
|
|
2927
|
+
// @ts-ignore
|
|
2928
|
+
// @ts-ignore
|
|
2929
|
+
// @ts-ignore
|
|
2930
|
+
// @ts-ignore
|
|
2919
2931
|
type PlaywrightConfig = {
|
|
2920
2932
|
url?: string;
|
|
2921
2933
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6292,6 +6304,10 @@ declare namespace CodeceptJS {
|
|
|
6292
6304
|
* @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
|
|
6293
6305
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
6294
6306
|
*/
|
|
6307
|
+
// @ts-ignore
|
|
6308
|
+
// @ts-ignore
|
|
6309
|
+
// @ts-ignore
|
|
6310
|
+
// @ts-ignore
|
|
6295
6311
|
type PuppeteerConfig = {
|
|
6296
6312
|
url: string;
|
|
6297
6313
|
basicAuth?: any;
|
|
@@ -8098,6 +8114,10 @@ declare namespace CodeceptJS {
|
|
|
8098
8114
|
* @property [onResponse] - an async function which can update response object.
|
|
8099
8115
|
* @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
8100
8116
|
*/
|
|
8117
|
+
// @ts-ignore
|
|
8118
|
+
// @ts-ignore
|
|
8119
|
+
// @ts-ignore
|
|
8120
|
+
// @ts-ignore
|
|
8101
8121
|
type RESTConfig = {
|
|
8102
8122
|
endpoint?: string;
|
|
8103
8123
|
prettyPrintJson?: boolean;
|
|
@@ -9242,6 +9262,10 @@ declare namespace CodeceptJS {
|
|
|
9242
9262
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
9243
9263
|
* @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
|
|
9244
9264
|
*/
|
|
9265
|
+
// @ts-ignore
|
|
9266
|
+
// @ts-ignore
|
|
9267
|
+
// @ts-ignore
|
|
9268
|
+
// @ts-ignore
|
|
9245
9269
|
type WebDriverConfig = {
|
|
9246
9270
|
url: string;
|
|
9247
9271
|
browser: string;
|
package/typings/types.d.ts
CHANGED
|
@@ -1786,6 +1786,10 @@ declare namespace CodeceptJS {
|
|
|
1786
1786
|
* @property [host = "0.0.0.0"] - Mock server host
|
|
1787
1787
|
* @property [httpsOpts] - key & cert values are the paths to .key and .crt files
|
|
1788
1788
|
*/
|
|
1789
|
+
// @ts-ignore
|
|
1790
|
+
// @ts-ignore
|
|
1791
|
+
// @ts-ignore
|
|
1792
|
+
// @ts-ignore
|
|
1789
1793
|
type MockServerConfig = {
|
|
1790
1794
|
port?: number;
|
|
1791
1795
|
host?: string;
|
|
@@ -1910,6 +1914,10 @@ declare namespace CodeceptJS {
|
|
|
1910
1914
|
*
|
|
1911
1915
|
* ## Methods
|
|
1912
1916
|
*/
|
|
1917
|
+
// @ts-ignore
|
|
1918
|
+
// @ts-ignore
|
|
1919
|
+
// @ts-ignore
|
|
1920
|
+
// @ts-ignore
|
|
1913
1921
|
class MockServer {
|
|
1914
1922
|
/**
|
|
1915
1923
|
* Start the mock server
|
|
@@ -3009,6 +3017,10 @@ declare namespace CodeceptJS {
|
|
|
3009
3017
|
* @property [recordHar] - record HAR and will be saved to `output/har`. See more of [HAR options](https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har).
|
|
3010
3018
|
* @property [testIdAttribute = data-testid] - locate elements based on the testIdAttribute. See more of [locate by test id](https://playwright.dev/docs/locators#locate-by-test-id).
|
|
3011
3019
|
*/
|
|
3020
|
+
// @ts-ignore
|
|
3021
|
+
// @ts-ignore
|
|
3022
|
+
// @ts-ignore
|
|
3023
|
+
// @ts-ignore
|
|
3012
3024
|
type PlaywrightConfig = {
|
|
3013
3025
|
url?: string;
|
|
3014
3026
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6536,6 +6548,10 @@ declare namespace CodeceptJS {
|
|
|
6536
6548
|
* @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
|
|
6537
6549
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
6538
6550
|
*/
|
|
6551
|
+
// @ts-ignore
|
|
6552
|
+
// @ts-ignore
|
|
6553
|
+
// @ts-ignore
|
|
6554
|
+
// @ts-ignore
|
|
6539
6555
|
type PuppeteerConfig = {
|
|
6540
6556
|
url: string;
|
|
6541
6557
|
basicAuth?: any;
|
|
@@ -8478,6 +8494,10 @@ declare namespace CodeceptJS {
|
|
|
8478
8494
|
* @property [onResponse] - an async function which can update response object.
|
|
8479
8495
|
* @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
8480
8496
|
*/
|
|
8497
|
+
// @ts-ignore
|
|
8498
|
+
// @ts-ignore
|
|
8499
|
+
// @ts-ignore
|
|
8500
|
+
// @ts-ignore
|
|
8481
8501
|
type RESTConfig = {
|
|
8482
8502
|
endpoint?: string;
|
|
8483
8503
|
prettyPrintJson?: boolean;
|
|
@@ -9682,6 +9702,10 @@ declare namespace CodeceptJS {
|
|
|
9682
9702
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
9683
9703
|
* @property [logLevel = silent] - level of logging verbosity. Default: silent. Options: trace | debug | info | warn | error | silent. More info: https://webdriver.io/docs/configuration/#loglevel
|
|
9684
9704
|
*/
|
|
9705
|
+
// @ts-ignore
|
|
9706
|
+
// @ts-ignore
|
|
9707
|
+
// @ts-ignore
|
|
9708
|
+
// @ts-ignore
|
|
9685
9709
|
type WebDriverConfig = {
|
|
9686
9710
|
url: string;
|
|
9687
9711
|
browser: string;
|
|
@@ -12209,12 +12233,29 @@ declare namespace CodeceptJS {
|
|
|
12209
12233
|
* global values for current session
|
|
12210
12234
|
*/
|
|
12211
12235
|
namespace store {
|
|
12236
|
+
/**
|
|
12237
|
+
* If we are in --debug mode
|
|
12238
|
+
*/
|
|
12212
12239
|
var debugMode: boolean;
|
|
12240
|
+
/**
|
|
12241
|
+
* Is timeouts enabled
|
|
12242
|
+
*/
|
|
12213
12243
|
var timeouts: boolean;
|
|
12244
|
+
/**
|
|
12245
|
+
* If auto-retries are enabled by retryFailedStep plugin
|
|
12246
|
+
* tryTo effect disables them
|
|
12247
|
+
*/
|
|
12248
|
+
var autoRetries: boolean;
|
|
12249
|
+
/**
|
|
12250
|
+
* Tests are executed via dry-run
|
|
12251
|
+
*/
|
|
12214
12252
|
var dryRun: boolean;
|
|
12253
|
+
/**
|
|
12254
|
+
* If we are in pause mode
|
|
12255
|
+
*/
|
|
12215
12256
|
var onPause: boolean;
|
|
12216
12257
|
var currentTest: CodeceptJS.Test | null;
|
|
12217
|
-
var currentStep:
|
|
12258
|
+
var currentStep: CodeceptJS.Step | null;
|
|
12218
12259
|
var currentSuite: CodeceptJS.Suite | null;
|
|
12219
12260
|
}
|
|
12220
12261
|
/**
|
|
@@ -12355,6 +12396,9 @@ declare namespace CodeceptJS {
|
|
|
12355
12396
|
*/
|
|
12356
12397
|
err: Error | null;
|
|
12357
12398
|
}
|
|
12399
|
+
/**
|
|
12400
|
+
* TODO: move to effects
|
|
12401
|
+
*/
|
|
12358
12402
|
function within(context: CodeceptJS.LocatorOrString, fn: (...params: any[]) => any): Promise<any> | undefined;
|
|
12359
12403
|
/**
|
|
12360
12404
|
* This is a wrapper on top of [Detox](https://github.com/wix/Detox) library, aimied to unify testing experience for CodeceptJS framework.
|