codeceptjs 3.7.0-beta.2 → 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 +27 -1
- package/lib/step/section.js +25 -0
- package/package.json +1 -1
- package/typings/promiseBasedTypes.d.ts +1 -43
- package/typings/types.d.ts +39 -70
|
@@ -3,7 +3,9 @@ const output = require('../output')
|
|
|
3
3
|
const recorder = require('../recorder')
|
|
4
4
|
const Config = require('../config')
|
|
5
5
|
const { timeouts } = require('../store')
|
|
6
|
+
const debug = require('debug')('codeceptjs:timeout')
|
|
6
7
|
const TIMEOUT_ORDER = require('../step').TIMEOUT_ORDER
|
|
8
|
+
const { BeforeSuiteHook, AfterSuiteHook } = require('../mocha/hooks')
|
|
7
9
|
|
|
8
10
|
module.exports = function () {
|
|
9
11
|
let timeout
|
|
@@ -16,12 +18,23 @@ module.exports = function () {
|
|
|
16
18
|
return
|
|
17
19
|
}
|
|
18
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
|
+
|
|
19
32
|
event.dispatcher.on(event.suite.before, suite => {
|
|
20
|
-
timeout = null;
|
|
21
33
|
suiteTimeout = []
|
|
22
34
|
let timeoutConfig = Config.get('timeout')
|
|
23
35
|
|
|
24
36
|
if (timeoutConfig) {
|
|
37
|
+
debug('config:', timeoutConfig)
|
|
25
38
|
if (!Number.isNaN(+timeoutConfig)) {
|
|
26
39
|
checkForSeconds(timeoutConfig)
|
|
27
40
|
suiteTimeout.push(timeoutConfig)
|
|
@@ -41,6 +54,8 @@ module.exports = function () {
|
|
|
41
54
|
|
|
42
55
|
if (suite.totalTimeout) suiteTimeout.push(suite.totalTimeout)
|
|
43
56
|
output.log(`Timeouts: ${suiteTimeout}`)
|
|
57
|
+
|
|
58
|
+
if (suiteTimeout.length > 0) debug(suite.title, 'timeout', suiteTimeout)
|
|
44
59
|
})
|
|
45
60
|
|
|
46
61
|
event.dispatcher.on(event.test.before, test => {
|
|
@@ -65,6 +80,13 @@ module.exports = function () {
|
|
|
65
80
|
|
|
66
81
|
timeout = test.totalTimeout || testTimeout || suiteTimeout[suiteTimeout.length - 1]
|
|
67
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
|
+
|
|
68
90
|
currentTimeout = timeout
|
|
69
91
|
output.debug(`Test Timeout: ${timeout}s`)
|
|
70
92
|
timeout *= 1000
|
|
@@ -82,8 +104,10 @@ module.exports = function () {
|
|
|
82
104
|
if (typeof timeout !== 'number') return
|
|
83
105
|
|
|
84
106
|
if (timeout < 0) {
|
|
107
|
+
debug('Previous steps timed out, setting timeout to 0.01s')
|
|
85
108
|
step.setTimeout(0.01, TIMEOUT_ORDER.testOrSuite)
|
|
86
109
|
} else {
|
|
110
|
+
debug(`Setting timeout ${timeout}ms for step ${step.toCode().trim()}`)
|
|
87
111
|
step.setTimeout(timeout, TIMEOUT_ORDER.testOrSuite)
|
|
88
112
|
}
|
|
89
113
|
})
|
|
@@ -92,7 +116,9 @@ module.exports = function () {
|
|
|
92
116
|
if (typeof timeout === 'number' && !Number.isNaN(timeout)) timeout -= step.duration
|
|
93
117
|
|
|
94
118
|
if (typeof timeout === 'number' && timeout <= 0 && recorder.isRunning()) {
|
|
119
|
+
debug(`step ${step.toCode().trim()} timed out`)
|
|
95
120
|
if (currentTest && currentTest.callback) {
|
|
121
|
+
debug(`Failing test ${currentTest.title} with timeout ${currentTimeout}s`)
|
|
96
122
|
recorder.reset()
|
|
97
123
|
// replace mocha timeout with custom timeout
|
|
98
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,12 +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
1770
|
type MockServerConfig = {
|
|
1783
1771
|
port?: number;
|
|
1784
1772
|
host?: string;
|
|
@@ -1911,12 +1899,6 @@ declare namespace CodeceptJS {
|
|
|
1911
1899
|
// @ts-ignore
|
|
1912
1900
|
// @ts-ignore
|
|
1913
1901
|
// @ts-ignore
|
|
1914
|
-
// @ts-ignore
|
|
1915
|
-
// @ts-ignore
|
|
1916
|
-
// @ts-ignore
|
|
1917
|
-
// @ts-ignore
|
|
1918
|
-
// @ts-ignore
|
|
1919
|
-
// @ts-ignore
|
|
1920
1902
|
class MockServer {
|
|
1921
1903
|
/**
|
|
1922
1904
|
* Start the mock server
|
|
@@ -2958,12 +2940,6 @@ declare namespace CodeceptJS {
|
|
|
2958
2940
|
// @ts-ignore
|
|
2959
2941
|
// @ts-ignore
|
|
2960
2942
|
// @ts-ignore
|
|
2961
|
-
// @ts-ignore
|
|
2962
|
-
// @ts-ignore
|
|
2963
|
-
// @ts-ignore
|
|
2964
|
-
// @ts-ignore
|
|
2965
|
-
// @ts-ignore
|
|
2966
|
-
// @ts-ignore
|
|
2967
2943
|
type PlaywrightConfig = {
|
|
2968
2944
|
url?: string;
|
|
2969
2945
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6348,12 +6324,6 @@ declare namespace CodeceptJS {
|
|
|
6348
6324
|
// @ts-ignore
|
|
6349
6325
|
// @ts-ignore
|
|
6350
6326
|
// @ts-ignore
|
|
6351
|
-
// @ts-ignore
|
|
6352
|
-
// @ts-ignore
|
|
6353
|
-
// @ts-ignore
|
|
6354
|
-
// @ts-ignore
|
|
6355
|
-
// @ts-ignore
|
|
6356
|
-
// @ts-ignore
|
|
6357
6327
|
type PuppeteerConfig = {
|
|
6358
6328
|
url: string;
|
|
6359
6329
|
basicAuth?: any;
|
|
@@ -8168,12 +8138,6 @@ declare namespace CodeceptJS {
|
|
|
8168
8138
|
// @ts-ignore
|
|
8169
8139
|
// @ts-ignore
|
|
8170
8140
|
// @ts-ignore
|
|
8171
|
-
// @ts-ignore
|
|
8172
|
-
// @ts-ignore
|
|
8173
|
-
// @ts-ignore
|
|
8174
|
-
// @ts-ignore
|
|
8175
|
-
// @ts-ignore
|
|
8176
|
-
// @ts-ignore
|
|
8177
8141
|
type RESTConfig = {
|
|
8178
8142
|
endpoint?: string;
|
|
8179
8143
|
prettyPrintJson?: boolean;
|
|
@@ -9326,12 +9290,6 @@ declare namespace CodeceptJS {
|
|
|
9326
9290
|
// @ts-ignore
|
|
9327
9291
|
// @ts-ignore
|
|
9328
9292
|
// @ts-ignore
|
|
9329
|
-
// @ts-ignore
|
|
9330
|
-
// @ts-ignore
|
|
9331
|
-
// @ts-ignore
|
|
9332
|
-
// @ts-ignore
|
|
9333
|
-
// @ts-ignore
|
|
9334
|
-
// @ts-ignore
|
|
9335
9293
|
type WebDriverConfig = {
|
|
9336
9294
|
url: string;
|
|
9337
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,12 +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
1797
|
type MockServerConfig = {
|
|
1810
1798
|
port?: number;
|
|
1811
1799
|
host?: string;
|
|
@@ -1938,12 +1926,6 @@ declare namespace CodeceptJS {
|
|
|
1938
1926
|
// @ts-ignore
|
|
1939
1927
|
// @ts-ignore
|
|
1940
1928
|
// @ts-ignore
|
|
1941
|
-
// @ts-ignore
|
|
1942
|
-
// @ts-ignore
|
|
1943
|
-
// @ts-ignore
|
|
1944
|
-
// @ts-ignore
|
|
1945
|
-
// @ts-ignore
|
|
1946
|
-
// @ts-ignore
|
|
1947
1929
|
class MockServer {
|
|
1948
1930
|
/**
|
|
1949
1931
|
* Start the mock server
|
|
@@ -3051,12 +3033,6 @@ declare namespace CodeceptJS {
|
|
|
3051
3033
|
// @ts-ignore
|
|
3052
3034
|
// @ts-ignore
|
|
3053
3035
|
// @ts-ignore
|
|
3054
|
-
// @ts-ignore
|
|
3055
|
-
// @ts-ignore
|
|
3056
|
-
// @ts-ignore
|
|
3057
|
-
// @ts-ignore
|
|
3058
|
-
// @ts-ignore
|
|
3059
|
-
// @ts-ignore
|
|
3060
3036
|
type PlaywrightConfig = {
|
|
3061
3037
|
url?: string;
|
|
3062
3038
|
browser?: 'chromium' | 'firefox' | 'webkit' | 'electron';
|
|
@@ -6592,12 +6568,6 @@ declare namespace CodeceptJS {
|
|
|
6592
6568
|
// @ts-ignore
|
|
6593
6569
|
// @ts-ignore
|
|
6594
6570
|
// @ts-ignore
|
|
6595
|
-
// @ts-ignore
|
|
6596
|
-
// @ts-ignore
|
|
6597
|
-
// @ts-ignore
|
|
6598
|
-
// @ts-ignore
|
|
6599
|
-
// @ts-ignore
|
|
6600
|
-
// @ts-ignore
|
|
6601
6571
|
type PuppeteerConfig = {
|
|
6602
6572
|
url: string;
|
|
6603
6573
|
basicAuth?: any;
|
|
@@ -8548,12 +8518,6 @@ declare namespace CodeceptJS {
|
|
|
8548
8518
|
// @ts-ignore
|
|
8549
8519
|
// @ts-ignore
|
|
8550
8520
|
// @ts-ignore
|
|
8551
|
-
// @ts-ignore
|
|
8552
|
-
// @ts-ignore
|
|
8553
|
-
// @ts-ignore
|
|
8554
|
-
// @ts-ignore
|
|
8555
|
-
// @ts-ignore
|
|
8556
|
-
// @ts-ignore
|
|
8557
8521
|
type RESTConfig = {
|
|
8558
8522
|
endpoint?: string;
|
|
8559
8523
|
prettyPrintJson?: boolean;
|
|
@@ -9766,12 +9730,6 @@ declare namespace CodeceptJS {
|
|
|
9766
9730
|
// @ts-ignore
|
|
9767
9731
|
// @ts-ignore
|
|
9768
9732
|
// @ts-ignore
|
|
9769
|
-
// @ts-ignore
|
|
9770
|
-
// @ts-ignore
|
|
9771
|
-
// @ts-ignore
|
|
9772
|
-
// @ts-ignore
|
|
9773
|
-
// @ts-ignore
|
|
9774
|
-
// @ts-ignore
|
|
9775
9733
|
type WebDriverConfig = {
|
|
9776
9734
|
url: string;
|
|
9777
9735
|
browser: string;
|
|
@@ -12207,24 +12165,49 @@ declare namespace CodeceptJS {
|
|
|
12207
12165
|
function session(sessionName: CodeceptJS.LocatorOrString, config: ((...params: any[]) => any) | {
|
|
12208
12166
|
[key: string]: any;
|
|
12209
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
|
+
}
|
|
12210
12193
|
/**
|
|
12211
12194
|
* Each command in test executed through `I.` object is wrapped in Step.
|
|
12212
12195
|
* Step allows logging executed commands and triggers hook before and after step execution.
|
|
12213
12196
|
*/
|
|
12214
12197
|
class Step {
|
|
12215
|
-
constructor(
|
|
12216
|
-
actor: string;
|
|
12217
|
-
helper: CodeceptJS.Helper;
|
|
12198
|
+
constructor(name: string);
|
|
12218
12199
|
name: string;
|
|
12200
|
+
timeouts: Map<number, number>;
|
|
12201
|
+
args: any[];
|
|
12202
|
+
opts: Record<string, any>;
|
|
12203
|
+
actor: string;
|
|
12219
12204
|
helperMethod: string;
|
|
12220
12205
|
status: string;
|
|
12221
|
-
suffix: string;
|
|
12222
12206
|
prefix: string;
|
|
12223
12207
|
comment: string;
|
|
12224
|
-
|
|
12225
|
-
metaStep: MetaStep;
|
|
12208
|
+
metaStep: any;
|
|
12226
12209
|
stack: string;
|
|
12227
|
-
|
|
12210
|
+
timeout: any;
|
|
12228
12211
|
/**
|
|
12229
12212
|
* @param timeout - timeout in milliseconds or 0 if no timeout
|
|
12230
12213
|
* @param order - order defines the priority of timeout, timeouts set with lower order override those set with higher order.
|
|
@@ -12233,7 +12216,6 @@ declare namespace CodeceptJS {
|
|
|
12233
12216
|
setTimeout(timeout: number, order: number): void;
|
|
12234
12217
|
setTrace(): void;
|
|
12235
12218
|
setArguments(args: any[]): void;
|
|
12236
|
-
run(...args: any[]): any;
|
|
12237
12219
|
setStatus(status: string): void;
|
|
12238
12220
|
humanize(): string;
|
|
12239
12221
|
humanizeArgs(): string;
|
|
@@ -12242,11 +12224,6 @@ declare namespace CodeceptJS {
|
|
|
12242
12224
|
toCliStyled(): string;
|
|
12243
12225
|
toCode(): string;
|
|
12244
12226
|
hasBDDAncestor(): boolean;
|
|
12245
|
-
static MetaStep: typeof MetaStep;
|
|
12246
|
-
}
|
|
12247
|
-
class MetaStep extends Step {
|
|
12248
|
-
isBDD(): boolean;
|
|
12249
|
-
run(): any;
|
|
12250
12227
|
}
|
|
12251
12228
|
/**
|
|
12252
12229
|
* global values for current session
|
|
@@ -12255,7 +12232,9 @@ declare namespace CodeceptJS {
|
|
|
12255
12232
|
var debugMode: boolean;
|
|
12256
12233
|
var timeouts: boolean;
|
|
12257
12234
|
var dryRun: boolean;
|
|
12235
|
+
var onPause: boolean;
|
|
12258
12236
|
var currentTest: CodeceptJS.Test | null;
|
|
12237
|
+
var currentStep: any;
|
|
12259
12238
|
}
|
|
12260
12239
|
/**
|
|
12261
12240
|
* Describe a "suite" with the given `title`
|
|
@@ -12948,22 +12927,12 @@ declare namespace CodeceptJS {
|
|
|
12948
12927
|
}
|
|
12949
12928
|
|
|
12950
12929
|
/**
|
|
12951
|
-
*
|
|
12952
|
-
*/
|
|
12953
|
-
declare var testOrSuite: any;
|
|
12954
|
-
|
|
12955
|
-
/**
|
|
12956
|
-
* 0-9 - designated for override of timeouts set from code, 5 is used by stepTimeout plugin when stepTimeout.config.overrideStepLimits=true
|
|
12957
|
-
*/
|
|
12958
|
-
declare var stepTimeoutHard: any;
|
|
12959
|
-
|
|
12960
|
-
/**
|
|
12961
|
-
* 10-19 - designated for timeouts set from code, 15 is order of I.setTimeout(t) operation
|
|
12930
|
+
* corresponding helper
|
|
12962
12931
|
*/
|
|
12963
|
-
declare var
|
|
12932
|
+
declare var helper: CodeceptJS.Helper;
|
|
12964
12933
|
|
|
12965
12934
|
/**
|
|
12966
|
-
*
|
|
12935
|
+
* name of method to be executed
|
|
12967
12936
|
*/
|
|
12968
|
-
declare var
|
|
12937
|
+
declare var helperMethod: string;
|
|
12969
12938
|
|