codeceptjs 3.7.0-beta.15 → 3.7.0-beta.16
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 +2 -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 +18 -0
- package/typings/types.d.ts +39 -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`)
|
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,9 @@ 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
|
|
1762
1765
|
type MockServerConfig = {
|
|
1763
1766
|
port?: number;
|
|
1764
1767
|
host?: string;
|
|
@@ -1883,6 +1886,9 @@ declare namespace CodeceptJS {
|
|
|
1883
1886
|
*
|
|
1884
1887
|
* ## Methods
|
|
1885
1888
|
*/
|
|
1889
|
+
// @ts-ignore
|
|
1890
|
+
// @ts-ignore
|
|
1891
|
+
// @ts-ignore
|
|
1886
1892
|
class MockServer {
|
|
1887
1893
|
/**
|
|
1888
1894
|
* Start the mock server
|
|
@@ -2916,6 +2922,9 @@ declare namespace CodeceptJS {
|
|
|
2916
2922
|
* @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
2923
|
* @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
2924
|
*/
|
|
2925
|
+
// @ts-ignore
|
|
2926
|
+
// @ts-ignore
|
|
2927
|
+
// @ts-ignore
|
|
2919
2928
|
type PlaywrightConfig = {
|
|
2920
2929
|
url?: string;
|
|
2921
2930
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6292,6 +6301,9 @@ declare namespace CodeceptJS {
|
|
|
6292
6301
|
* @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
|
|
6293
6302
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
6294
6303
|
*/
|
|
6304
|
+
// @ts-ignore
|
|
6305
|
+
// @ts-ignore
|
|
6306
|
+
// @ts-ignore
|
|
6295
6307
|
type PuppeteerConfig = {
|
|
6296
6308
|
url: string;
|
|
6297
6309
|
basicAuth?: any;
|
|
@@ -8098,6 +8110,9 @@ declare namespace CodeceptJS {
|
|
|
8098
8110
|
* @property [onResponse] - an async function which can update response object.
|
|
8099
8111
|
* @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
8100
8112
|
*/
|
|
8113
|
+
// @ts-ignore
|
|
8114
|
+
// @ts-ignore
|
|
8115
|
+
// @ts-ignore
|
|
8101
8116
|
type RESTConfig = {
|
|
8102
8117
|
endpoint?: string;
|
|
8103
8118
|
prettyPrintJson?: boolean;
|
|
@@ -9242,6 +9257,9 @@ declare namespace CodeceptJS {
|
|
|
9242
9257
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
9243
9258
|
* @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
9259
|
*/
|
|
9260
|
+
// @ts-ignore
|
|
9261
|
+
// @ts-ignore
|
|
9262
|
+
// @ts-ignore
|
|
9245
9263
|
type WebDriverConfig = {
|
|
9246
9264
|
url: string;
|
|
9247
9265
|
browser: string;
|
package/typings/types.d.ts
CHANGED
|
@@ -1786,6 +1786,9 @@ 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
|
|
1789
1792
|
type MockServerConfig = {
|
|
1790
1793
|
port?: number;
|
|
1791
1794
|
host?: string;
|
|
@@ -1910,6 +1913,9 @@ declare namespace CodeceptJS {
|
|
|
1910
1913
|
*
|
|
1911
1914
|
* ## Methods
|
|
1912
1915
|
*/
|
|
1916
|
+
// @ts-ignore
|
|
1917
|
+
// @ts-ignore
|
|
1918
|
+
// @ts-ignore
|
|
1913
1919
|
class MockServer {
|
|
1914
1920
|
/**
|
|
1915
1921
|
* Start the mock server
|
|
@@ -3009,6 +3015,9 @@ declare namespace CodeceptJS {
|
|
|
3009
3015
|
* @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
3016
|
* @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
3017
|
*/
|
|
3018
|
+
// @ts-ignore
|
|
3019
|
+
// @ts-ignore
|
|
3020
|
+
// @ts-ignore
|
|
3012
3021
|
type PlaywrightConfig = {
|
|
3013
3022
|
url?: string;
|
|
3014
3023
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6536,6 +6545,9 @@ declare namespace CodeceptJS {
|
|
|
6536
6545
|
* @property [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
|
|
6537
6546
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
6538
6547
|
*/
|
|
6548
|
+
// @ts-ignore
|
|
6549
|
+
// @ts-ignore
|
|
6550
|
+
// @ts-ignore
|
|
6539
6551
|
type PuppeteerConfig = {
|
|
6540
6552
|
url: string;
|
|
6541
6553
|
basicAuth?: any;
|
|
@@ -8478,6 +8490,9 @@ declare namespace CodeceptJS {
|
|
|
8478
8490
|
* @property [onResponse] - an async function which can update response object.
|
|
8479
8491
|
* @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
8480
8492
|
*/
|
|
8493
|
+
// @ts-ignore
|
|
8494
|
+
// @ts-ignore
|
|
8495
|
+
// @ts-ignore
|
|
8481
8496
|
type RESTConfig = {
|
|
8482
8497
|
endpoint?: string;
|
|
8483
8498
|
prettyPrintJson?: boolean;
|
|
@@ -9682,6 +9697,9 @@ declare namespace CodeceptJS {
|
|
|
9682
9697
|
* @property [highlightElement] - highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
|
|
9683
9698
|
* @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
9699
|
*/
|
|
9700
|
+
// @ts-ignore
|
|
9701
|
+
// @ts-ignore
|
|
9702
|
+
// @ts-ignore
|
|
9685
9703
|
type WebDriverConfig = {
|
|
9686
9704
|
url: string;
|
|
9687
9705
|
browser: string;
|
|
@@ -12209,12 +12227,29 @@ declare namespace CodeceptJS {
|
|
|
12209
12227
|
* global values for current session
|
|
12210
12228
|
*/
|
|
12211
12229
|
namespace store {
|
|
12230
|
+
/**
|
|
12231
|
+
* If we are in --debug mode
|
|
12232
|
+
*/
|
|
12212
12233
|
var debugMode: boolean;
|
|
12234
|
+
/**
|
|
12235
|
+
* Is timeouts enabled
|
|
12236
|
+
*/
|
|
12213
12237
|
var timeouts: boolean;
|
|
12238
|
+
/**
|
|
12239
|
+
* If auto-retries are enabled by retryFailedStep plugin
|
|
12240
|
+
* tryTo effect disables them
|
|
12241
|
+
*/
|
|
12242
|
+
var autoRetries: boolean;
|
|
12243
|
+
/**
|
|
12244
|
+
* Tests are executed via dry-run
|
|
12245
|
+
*/
|
|
12214
12246
|
var dryRun: boolean;
|
|
12247
|
+
/**
|
|
12248
|
+
* If we are in pause mode
|
|
12249
|
+
*/
|
|
12215
12250
|
var onPause: boolean;
|
|
12216
12251
|
var currentTest: CodeceptJS.Test | null;
|
|
12217
|
-
var currentStep:
|
|
12252
|
+
var currentStep: CodeceptJS.Step | null;
|
|
12218
12253
|
var currentSuite: CodeceptJS.Suite | null;
|
|
12219
12254
|
}
|
|
12220
12255
|
/**
|
|
@@ -12355,6 +12390,9 @@ declare namespace CodeceptJS {
|
|
|
12355
12390
|
*/
|
|
12356
12391
|
err: Error | null;
|
|
12357
12392
|
}
|
|
12393
|
+
/**
|
|
12394
|
+
* TODO: move to effects
|
|
12395
|
+
*/
|
|
12358
12396
|
function within(context: CodeceptJS.LocatorOrString, fn: (...params: any[]) => any): Promise<any> | undefined;
|
|
12359
12397
|
/**
|
|
12360
12398
|
* This is a wrapper on top of [Detox](https://github.com/wix/Detox) library, aimied to unify testing experience for CodeceptJS framework.
|