codeceptjs 3.7.0-beta.3 → 3.7.0-beta.4
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/lib/listener/globalTimeout.js +26 -8
- package/lib/step/section.js +25 -0
- package/package.json +1 -1
- package/typings/promiseBasedTypes.d.ts +1 -49
- package/typings/types.d.ts +39 -76
|
@@ -5,6 +5,7 @@ const Config = require('../config')
|
|
|
5
5
|
const { timeouts } = require('../store')
|
|
6
6
|
const debug = require('debug')('codeceptjs:timeout')
|
|
7
7
|
const TIMEOUT_ORDER = require('../step').TIMEOUT_ORDER
|
|
8
|
+
const { BeforeSuiteHook, AfterSuiteHook } = require('../mocha/hooks')
|
|
8
9
|
|
|
9
10
|
module.exports = function () {
|
|
10
11
|
let timeout
|
|
@@ -17,13 +18,23 @@ module.exports = function () {
|
|
|
17
18
|
return
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
// disable timeout for BeforeSuite/AfterSuite hooks
|
|
22
|
+
// add separate configs to them?
|
|
23
|
+
event.dispatcher.on(event.hook.started, hook => {
|
|
24
|
+
if (hook instanceof BeforeSuiteHook) {
|
|
25
|
+
suiteTimeout = []
|
|
26
|
+
}
|
|
27
|
+
if (hook instanceof AfterSuiteHook) {
|
|
28
|
+
suiteTimeout = []
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
20
32
|
event.dispatcher.on(event.suite.before, suite => {
|
|
21
33
|
suiteTimeout = []
|
|
22
34
|
let timeoutConfig = Config.get('timeout')
|
|
23
35
|
|
|
24
|
-
debug('config:', timeoutConfig || 'none')
|
|
25
|
-
|
|
26
36
|
if (timeoutConfig) {
|
|
37
|
+
debug('config:', timeoutConfig)
|
|
27
38
|
if (!Number.isNaN(+timeoutConfig)) {
|
|
28
39
|
checkForSeconds(timeoutConfig)
|
|
29
40
|
suiteTimeout.push(timeoutConfig)
|
|
@@ -41,10 +52,10 @@ module.exports = function () {
|
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
debug('current suite timeout:', suite.totalTimeout || 'none');
|
|
45
55
|
if (suite.totalTimeout) suiteTimeout.push(suite.totalTimeout)
|
|
46
56
|
output.log(`Timeouts: ${suiteTimeout}`)
|
|
47
|
-
|
|
57
|
+
|
|
58
|
+
if (suiteTimeout.length > 0) debug(suite.title, 'timeout', suiteTimeout)
|
|
48
59
|
})
|
|
49
60
|
|
|
50
61
|
event.dispatcher.on(event.test.before, test => {
|
|
@@ -69,6 +80,13 @@ module.exports = function () {
|
|
|
69
80
|
|
|
70
81
|
timeout = test.totalTimeout || testTimeout || suiteTimeout[suiteTimeout.length - 1]
|
|
71
82
|
if (!timeout) return
|
|
83
|
+
|
|
84
|
+
debug(test.title, 'timeout', {
|
|
85
|
+
'config from file': testTimeout,
|
|
86
|
+
'suite timeout': suiteTimeout,
|
|
87
|
+
'dynamic config': test.totalTimeout,
|
|
88
|
+
})
|
|
89
|
+
|
|
72
90
|
currentTimeout = timeout
|
|
73
91
|
output.debug(`Test Timeout: ${timeout}s`)
|
|
74
92
|
timeout *= 1000
|
|
@@ -86,10 +104,10 @@ module.exports = function () {
|
|
|
86
104
|
if (typeof timeout !== 'number') return
|
|
87
105
|
|
|
88
106
|
if (timeout < 0) {
|
|
89
|
-
debug('Previous steps timed out, setting timeout to 0.01s')
|
|
107
|
+
debug('Previous steps timed out, setting timeout to 0.01s')
|
|
90
108
|
step.setTimeout(0.01, TIMEOUT_ORDER.testOrSuite)
|
|
91
109
|
} else {
|
|
92
|
-
debug(`Setting timeout ${timeout}ms for step ${step.toCode().trim()}`)
|
|
110
|
+
debug(`Setting timeout ${timeout}ms for step ${step.toCode().trim()}`)
|
|
93
111
|
step.setTimeout(timeout, TIMEOUT_ORDER.testOrSuite)
|
|
94
112
|
}
|
|
95
113
|
})
|
|
@@ -98,9 +116,9 @@ module.exports = function () {
|
|
|
98
116
|
if (typeof timeout === 'number' && !Number.isNaN(timeout)) timeout -= step.duration
|
|
99
117
|
|
|
100
118
|
if (typeof timeout === 'number' && timeout <= 0 && recorder.isRunning()) {
|
|
101
|
-
debug(`step ${step.toCode().trim()} timed out`)
|
|
119
|
+
debug(`step ${step.toCode().trim()} timed out`)
|
|
102
120
|
if (currentTest && currentTest.callback) {
|
|
103
|
-
debug(`Failing test ${currentTest.title} with timeout ${currentTimeout}s`)
|
|
121
|
+
debug(`Failing test ${currentTest.title} with timeout ${currentTimeout}s`)
|
|
104
122
|
recorder.reset()
|
|
105
123
|
// replace mocha timeout with custom timeout
|
|
106
124
|
currentTest.timeout(0)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const event = require('../event')
|
|
2
|
+
|
|
3
|
+
class Section {
|
|
4
|
+
constructor(name = '') {
|
|
5
|
+
this.name = name
|
|
6
|
+
|
|
7
|
+
this.attachMetaStep = (step) => {
|
|
8
|
+
console.log('attach meta step', this.name)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
start() {
|
|
13
|
+
event.dispatcher.on(event.step.started, this.attachMetaStep)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
end() {
|
|
17
|
+
event.dispatcher.off(event.step.started, this.attachMetaStep)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function getRootMetaStep(step) {
|
|
23
|
+
if (step.metaStep) return getRootMetaStep(step.metaStep)
|
|
24
|
+
return step
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -608,17 +608,11 @@ declare namespace CodeceptJS {
|
|
|
608
608
|
* ```js
|
|
609
609
|
* // taps outside to hide keyboard per default
|
|
610
610
|
* I.hideDeviceKeyboard();
|
|
611
|
-
* I.hideDeviceKeyboard('tapOutside');
|
|
612
|
-
*
|
|
613
|
-
* // or by pressing key
|
|
614
|
-
* I.hideDeviceKeyboard('pressKey', 'Done');
|
|
615
611
|
* ```
|
|
616
612
|
*
|
|
617
613
|
* Appium: support Android and iOS
|
|
618
|
-
* @param [strategy] - Desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
|
|
619
|
-
* @param [key] - Optional key
|
|
620
614
|
*/
|
|
621
|
-
hideDeviceKeyboard(
|
|
615
|
+
hideDeviceKeyboard(): Promise<any>;
|
|
622
616
|
/**
|
|
623
617
|
* Send a key event to the device.
|
|
624
618
|
* List of keys: https://developer.android.com/reference/android/view/KeyEvent.html
|
|
@@ -1773,13 +1767,6 @@ declare namespace CodeceptJS {
|
|
|
1773
1767
|
// @ts-ignore
|
|
1774
1768
|
// @ts-ignore
|
|
1775
1769
|
// @ts-ignore
|
|
1776
|
-
// @ts-ignore
|
|
1777
|
-
// @ts-ignore
|
|
1778
|
-
// @ts-ignore
|
|
1779
|
-
// @ts-ignore
|
|
1780
|
-
// @ts-ignore
|
|
1781
|
-
// @ts-ignore
|
|
1782
|
-
// @ts-ignore
|
|
1783
1770
|
type MockServerConfig = {
|
|
1784
1771
|
port?: number;
|
|
1785
1772
|
host?: string;
|
|
@@ -1912,13 +1899,6 @@ declare namespace CodeceptJS {
|
|
|
1912
1899
|
// @ts-ignore
|
|
1913
1900
|
// @ts-ignore
|
|
1914
1901
|
// @ts-ignore
|
|
1915
|
-
// @ts-ignore
|
|
1916
|
-
// @ts-ignore
|
|
1917
|
-
// @ts-ignore
|
|
1918
|
-
// @ts-ignore
|
|
1919
|
-
// @ts-ignore
|
|
1920
|
-
// @ts-ignore
|
|
1921
|
-
// @ts-ignore
|
|
1922
1902
|
class MockServer {
|
|
1923
1903
|
/**
|
|
1924
1904
|
* Start the mock server
|
|
@@ -2960,13 +2940,6 @@ declare namespace CodeceptJS {
|
|
|
2960
2940
|
// @ts-ignore
|
|
2961
2941
|
// @ts-ignore
|
|
2962
2942
|
// @ts-ignore
|
|
2963
|
-
// @ts-ignore
|
|
2964
|
-
// @ts-ignore
|
|
2965
|
-
// @ts-ignore
|
|
2966
|
-
// @ts-ignore
|
|
2967
|
-
// @ts-ignore
|
|
2968
|
-
// @ts-ignore
|
|
2969
|
-
// @ts-ignore
|
|
2970
2943
|
type PlaywrightConfig = {
|
|
2971
2944
|
url?: string;
|
|
2972
2945
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6351,13 +6324,6 @@ declare namespace CodeceptJS {
|
|
|
6351
6324
|
// @ts-ignore
|
|
6352
6325
|
// @ts-ignore
|
|
6353
6326
|
// @ts-ignore
|
|
6354
|
-
// @ts-ignore
|
|
6355
|
-
// @ts-ignore
|
|
6356
|
-
// @ts-ignore
|
|
6357
|
-
// @ts-ignore
|
|
6358
|
-
// @ts-ignore
|
|
6359
|
-
// @ts-ignore
|
|
6360
|
-
// @ts-ignore
|
|
6361
6327
|
type PuppeteerConfig = {
|
|
6362
6328
|
url: string;
|
|
6363
6329
|
basicAuth?: any;
|
|
@@ -8172,13 +8138,6 @@ declare namespace CodeceptJS {
|
|
|
8172
8138
|
// @ts-ignore
|
|
8173
8139
|
// @ts-ignore
|
|
8174
8140
|
// @ts-ignore
|
|
8175
|
-
// @ts-ignore
|
|
8176
|
-
// @ts-ignore
|
|
8177
|
-
// @ts-ignore
|
|
8178
|
-
// @ts-ignore
|
|
8179
|
-
// @ts-ignore
|
|
8180
|
-
// @ts-ignore
|
|
8181
|
-
// @ts-ignore
|
|
8182
8141
|
type RESTConfig = {
|
|
8183
8142
|
endpoint?: string;
|
|
8184
8143
|
prettyPrintJson?: boolean;
|
|
@@ -9331,13 +9290,6 @@ declare namespace CodeceptJS {
|
|
|
9331
9290
|
// @ts-ignore
|
|
9332
9291
|
// @ts-ignore
|
|
9333
9292
|
// @ts-ignore
|
|
9334
|
-
// @ts-ignore
|
|
9335
|
-
// @ts-ignore
|
|
9336
|
-
// @ts-ignore
|
|
9337
|
-
// @ts-ignore
|
|
9338
|
-
// @ts-ignore
|
|
9339
|
-
// @ts-ignore
|
|
9340
|
-
// @ts-ignore
|
|
9341
9293
|
type WebDriverConfig = {
|
|
9342
9294
|
url: string;
|
|
9343
9295
|
browser: string;
|
package/typings/types.d.ts
CHANGED
|
@@ -608,17 +608,11 @@ declare namespace CodeceptJS {
|
|
|
608
608
|
* ```js
|
|
609
609
|
* // taps outside to hide keyboard per default
|
|
610
610
|
* I.hideDeviceKeyboard();
|
|
611
|
-
* I.hideDeviceKeyboard('tapOutside');
|
|
612
|
-
*
|
|
613
|
-
* // or by pressing key
|
|
614
|
-
* I.hideDeviceKeyboard('pressKey', 'Done');
|
|
615
611
|
* ```
|
|
616
612
|
*
|
|
617
613
|
* Appium: support Android and iOS
|
|
618
|
-
* @param [strategy] - Desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
|
|
619
|
-
* @param [key] - Optional key
|
|
620
614
|
*/
|
|
621
|
-
hideDeviceKeyboard(
|
|
615
|
+
hideDeviceKeyboard(): void;
|
|
622
616
|
/**
|
|
623
617
|
* Send a key event to the device.
|
|
624
618
|
* List of keys: https://developer.android.com/reference/android/view/KeyEvent.html
|
|
@@ -1800,13 +1794,6 @@ declare namespace CodeceptJS {
|
|
|
1800
1794
|
// @ts-ignore
|
|
1801
1795
|
// @ts-ignore
|
|
1802
1796
|
// @ts-ignore
|
|
1803
|
-
// @ts-ignore
|
|
1804
|
-
// @ts-ignore
|
|
1805
|
-
// @ts-ignore
|
|
1806
|
-
// @ts-ignore
|
|
1807
|
-
// @ts-ignore
|
|
1808
|
-
// @ts-ignore
|
|
1809
|
-
// @ts-ignore
|
|
1810
1797
|
type MockServerConfig = {
|
|
1811
1798
|
port?: number;
|
|
1812
1799
|
host?: string;
|
|
@@ -1939,13 +1926,6 @@ declare namespace CodeceptJS {
|
|
|
1939
1926
|
// @ts-ignore
|
|
1940
1927
|
// @ts-ignore
|
|
1941
1928
|
// @ts-ignore
|
|
1942
|
-
// @ts-ignore
|
|
1943
|
-
// @ts-ignore
|
|
1944
|
-
// @ts-ignore
|
|
1945
|
-
// @ts-ignore
|
|
1946
|
-
// @ts-ignore
|
|
1947
|
-
// @ts-ignore
|
|
1948
|
-
// @ts-ignore
|
|
1949
1929
|
class MockServer {
|
|
1950
1930
|
/**
|
|
1951
1931
|
* Start the mock server
|
|
@@ -3053,13 +3033,6 @@ declare namespace CodeceptJS {
|
|
|
3053
3033
|
// @ts-ignore
|
|
3054
3034
|
// @ts-ignore
|
|
3055
3035
|
// @ts-ignore
|
|
3056
|
-
// @ts-ignore
|
|
3057
|
-
// @ts-ignore
|
|
3058
|
-
// @ts-ignore
|
|
3059
|
-
// @ts-ignore
|
|
3060
|
-
// @ts-ignore
|
|
3061
|
-
// @ts-ignore
|
|
3062
|
-
// @ts-ignore
|
|
3063
3036
|
type PlaywrightConfig = {
|
|
3064
3037
|
url?: string;
|
|
3065
3038
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6595,13 +6568,6 @@ declare namespace CodeceptJS {
|
|
|
6595
6568
|
// @ts-ignore
|
|
6596
6569
|
// @ts-ignore
|
|
6597
6570
|
// @ts-ignore
|
|
6598
|
-
// @ts-ignore
|
|
6599
|
-
// @ts-ignore
|
|
6600
|
-
// @ts-ignore
|
|
6601
|
-
// @ts-ignore
|
|
6602
|
-
// @ts-ignore
|
|
6603
|
-
// @ts-ignore
|
|
6604
|
-
// @ts-ignore
|
|
6605
6571
|
type PuppeteerConfig = {
|
|
6606
6572
|
url: string;
|
|
6607
6573
|
basicAuth?: any;
|
|
@@ -8552,13 +8518,6 @@ declare namespace CodeceptJS {
|
|
|
8552
8518
|
// @ts-ignore
|
|
8553
8519
|
// @ts-ignore
|
|
8554
8520
|
// @ts-ignore
|
|
8555
|
-
// @ts-ignore
|
|
8556
|
-
// @ts-ignore
|
|
8557
|
-
// @ts-ignore
|
|
8558
|
-
// @ts-ignore
|
|
8559
|
-
// @ts-ignore
|
|
8560
|
-
// @ts-ignore
|
|
8561
|
-
// @ts-ignore
|
|
8562
8521
|
type RESTConfig = {
|
|
8563
8522
|
endpoint?: string;
|
|
8564
8523
|
prettyPrintJson?: boolean;
|
|
@@ -9771,13 +9730,6 @@ declare namespace CodeceptJS {
|
|
|
9771
9730
|
// @ts-ignore
|
|
9772
9731
|
// @ts-ignore
|
|
9773
9732
|
// @ts-ignore
|
|
9774
|
-
// @ts-ignore
|
|
9775
|
-
// @ts-ignore
|
|
9776
|
-
// @ts-ignore
|
|
9777
|
-
// @ts-ignore
|
|
9778
|
-
// @ts-ignore
|
|
9779
|
-
// @ts-ignore
|
|
9780
|
-
// @ts-ignore
|
|
9781
9733
|
type WebDriverConfig = {
|
|
9782
9734
|
url: string;
|
|
9783
9735
|
browser: string;
|
|
@@ -12213,24 +12165,49 @@ declare namespace CodeceptJS {
|
|
|
12213
12165
|
function session(sessionName: CodeceptJS.LocatorOrString, config: ((...params: any[]) => any) | {
|
|
12214
12166
|
[key: string]: any;
|
|
12215
12167
|
}, fn?: (...params: any[]) => any): any;
|
|
12168
|
+
/**
|
|
12169
|
+
* StepConfig is a configuration object for a step.
|
|
12170
|
+
* It is used to create a new step that is a combination of other steps.
|
|
12171
|
+
*/
|
|
12172
|
+
class StepConfig {
|
|
12173
|
+
config: any;
|
|
12174
|
+
/**
|
|
12175
|
+
* Set the options for the step.
|
|
12176
|
+
* @param opts - The options for the step.
|
|
12177
|
+
* @returns - The step configuration object.
|
|
12178
|
+
*/
|
|
12179
|
+
opts(opts: any): StepConfig;
|
|
12180
|
+
/**
|
|
12181
|
+
* Set the timeout for the step.
|
|
12182
|
+
* @param timeout - The timeout for the step.
|
|
12183
|
+
* @returns - The step configuration object.
|
|
12184
|
+
*/
|
|
12185
|
+
timeout(timeout: number): StepConfig;
|
|
12186
|
+
/**
|
|
12187
|
+
* Set the retry for the step.
|
|
12188
|
+
* @param retry - The retry for the step.
|
|
12189
|
+
* @returns - The step configuration object.
|
|
12190
|
+
*/
|
|
12191
|
+
retry(retry: number): StepConfig;
|
|
12192
|
+
}
|
|
12216
12193
|
/**
|
|
12217
12194
|
* Each command in test executed through `I.` object is wrapped in Step.
|
|
12218
12195
|
* Step allows logging executed commands and triggers hook before and after step execution.
|
|
12219
12196
|
*/
|
|
12220
12197
|
class Step {
|
|
12221
|
-
constructor(
|
|
12222
|
-
actor: string;
|
|
12223
|
-
helper: CodeceptJS.Helper;
|
|
12198
|
+
constructor(name: string);
|
|
12224
12199
|
name: string;
|
|
12200
|
+
timeouts: Map<number, number>;
|
|
12201
|
+
args: any[];
|
|
12202
|
+
opts: Record<string, any>;
|
|
12203
|
+
actor: string;
|
|
12225
12204
|
helperMethod: string;
|
|
12226
12205
|
status: string;
|
|
12227
|
-
suffix: string;
|
|
12228
12206
|
prefix: string;
|
|
12229
12207
|
comment: string;
|
|
12230
|
-
|
|
12231
|
-
metaStep: MetaStep;
|
|
12208
|
+
metaStep: any;
|
|
12232
12209
|
stack: string;
|
|
12233
|
-
|
|
12210
|
+
timeout: any;
|
|
12234
12211
|
/**
|
|
12235
12212
|
* @param timeout - timeout in milliseconds or 0 if no timeout
|
|
12236
12213
|
* @param order - order defines the priority of timeout, timeouts set with lower order override those set with higher order.
|
|
@@ -12239,7 +12216,6 @@ declare namespace CodeceptJS {
|
|
|
12239
12216
|
setTimeout(timeout: number, order: number): void;
|
|
12240
12217
|
setTrace(): void;
|
|
12241
12218
|
setArguments(args: any[]): void;
|
|
12242
|
-
run(...args: any[]): any;
|
|
12243
12219
|
setStatus(status: string): void;
|
|
12244
12220
|
humanize(): string;
|
|
12245
12221
|
humanizeArgs(): string;
|
|
@@ -12248,11 +12224,6 @@ declare namespace CodeceptJS {
|
|
|
12248
12224
|
toCliStyled(): string;
|
|
12249
12225
|
toCode(): string;
|
|
12250
12226
|
hasBDDAncestor(): boolean;
|
|
12251
|
-
static MetaStep: typeof MetaStep;
|
|
12252
|
-
}
|
|
12253
|
-
class MetaStep extends Step {
|
|
12254
|
-
isBDD(): boolean;
|
|
12255
|
-
run(): any;
|
|
12256
12227
|
}
|
|
12257
12228
|
/**
|
|
12258
12229
|
* global values for current session
|
|
@@ -12261,7 +12232,9 @@ declare namespace CodeceptJS {
|
|
|
12261
12232
|
var debugMode: boolean;
|
|
12262
12233
|
var timeouts: boolean;
|
|
12263
12234
|
var dryRun: boolean;
|
|
12235
|
+
var onPause: boolean;
|
|
12264
12236
|
var currentTest: CodeceptJS.Test | null;
|
|
12237
|
+
var currentStep: any;
|
|
12265
12238
|
}
|
|
12266
12239
|
/**
|
|
12267
12240
|
* Describe a "suite" with the given `title`
|
|
@@ -12954,22 +12927,12 @@ declare namespace CodeceptJS {
|
|
|
12954
12927
|
}
|
|
12955
12928
|
|
|
12956
12929
|
/**
|
|
12957
|
-
*
|
|
12958
|
-
*/
|
|
12959
|
-
declare var testOrSuite: any;
|
|
12960
|
-
|
|
12961
|
-
/**
|
|
12962
|
-
* 0-9 - designated for override of timeouts set from code, 5 is used by stepTimeout plugin when stepTimeout.config.overrideStepLimits=true
|
|
12963
|
-
*/
|
|
12964
|
-
declare var stepTimeoutHard: any;
|
|
12965
|
-
|
|
12966
|
-
/**
|
|
12967
|
-
* 10-19 - designated for timeouts set from code, 15 is order of I.setTimeout(t) operation
|
|
12930
|
+
* corresponding helper
|
|
12968
12931
|
*/
|
|
12969
|
-
declare var
|
|
12932
|
+
declare var helper: CodeceptJS.Helper;
|
|
12970
12933
|
|
|
12971
12934
|
/**
|
|
12972
|
-
*
|
|
12935
|
+
* name of method to be executed
|
|
12973
12936
|
*/
|
|
12974
|
-
declare var
|
|
12937
|
+
declare var helperMethod: string;
|
|
12975
12938
|
|