codeceptjs 3.6.10 → 3.7.0-beta.1
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 +81 -110
- package/bin/codecept.js +2 -2
- package/docs/webapi/clearCookie.mustache +1 -1
- package/lib/actor.js +46 -36
- package/lib/assert/empty.js +3 -5
- package/lib/assert/equal.js +4 -7
- package/lib/assert/include.js +4 -6
- package/lib/assert/throws.js +2 -4
- package/lib/assert/truth.js +2 -2
- package/lib/codecept.js +87 -83
- package/lib/command/configMigrate.js +2 -4
- package/lib/command/definitions.js +5 -25
- package/lib/command/generate.js +10 -14
- package/lib/command/gherkin/snippets.js +10 -8
- package/lib/command/gherkin/steps.js +1 -1
- package/lib/command/info.js +1 -3
- package/lib/command/init.js +8 -12
- package/lib/command/interactive.js +1 -1
- package/lib/command/list.js +1 -1
- package/lib/command/run-multiple.js +12 -35
- package/lib/command/run-workers.js +10 -10
- package/lib/command/utils.js +5 -6
- package/lib/command/workers/runTests.js +14 -17
- package/lib/container.js +327 -237
- package/lib/data/context.js +10 -13
- package/lib/data/dataScenarioConfig.js +8 -8
- package/lib/data/dataTableArgument.js +6 -6
- package/lib/data/table.js +5 -11
- package/lib/els.js +177 -0
- package/lib/event.js +1 -0
- package/lib/heal.js +78 -80
- package/lib/helper/ApiDataFactory.js +3 -6
- package/lib/helper/Appium.js +15 -30
- package/lib/helper/FileSystem.js +3 -3
- package/lib/helper/GraphQLDataFactory.js +3 -3
- package/lib/helper/JSONResponse.js +57 -37
- package/lib/helper/Nightmare.js +35 -53
- package/lib/helper/Playwright.js +189 -251
- package/lib/helper/Protractor.js +54 -77
- package/lib/helper/Puppeteer.js +134 -232
- package/lib/helper/REST.js +5 -17
- package/lib/helper/TestCafe.js +21 -44
- package/lib/helper/WebDriver.js +103 -162
- package/lib/helper/testcafe/testcafe-utils.js +26 -27
- package/lib/listener/artifacts.js +2 -2
- package/lib/listener/emptyRun.js +58 -0
- package/lib/listener/exit.js +4 -4
- package/lib/listener/{retry.js → globalRetry.js} +5 -5
- package/lib/listener/{timeout.js → globalTimeout.js} +8 -8
- package/lib/listener/helpers.js +15 -15
- package/lib/listener/mocha.js +1 -1
- package/lib/listener/steps.js +17 -12
- package/lib/listener/store.js +12 -0
- package/lib/mocha/asyncWrapper.js +204 -0
- package/lib/{interfaces → mocha}/bdd.js +3 -3
- package/lib/mocha/cli.js +257 -0
- package/lib/mocha/factory.js +104 -0
- package/lib/{interfaces → mocha}/featureConfig.js +11 -12
- package/lib/{interfaces → mocha}/gherkin.js +26 -28
- package/lib/mocha/hooks.js +83 -0
- package/lib/mocha/index.js +12 -0
- package/lib/mocha/inject.js +24 -0
- package/lib/{interfaces → mocha}/scenarioConfig.js +10 -6
- package/lib/mocha/suite.js +55 -0
- package/lib/mocha/test.js +60 -0
- package/lib/mocha/types.d.ts +31 -0
- package/lib/mocha/ui.js +219 -0
- package/lib/output.js +28 -10
- package/lib/pause.js +159 -135
- package/lib/plugin/autoDelay.js +4 -4
- package/lib/plugin/autoLogin.js +6 -7
- package/lib/plugin/commentStep.js +1 -1
- package/lib/plugin/coverage.js +10 -19
- package/lib/plugin/customLocator.js +3 -3
- package/lib/plugin/debugErrors.js +2 -2
- package/lib/plugin/eachElement.js +1 -1
- package/lib/plugin/fakerTransform.js +1 -1
- package/lib/plugin/heal.js +6 -9
- package/lib/plugin/retryFailedStep.js +4 -4
- package/lib/plugin/retryTo.js +2 -2
- package/lib/plugin/screenshotOnFail.js +9 -36
- package/lib/plugin/selenoid.js +15 -35
- package/lib/plugin/stepByStepReport.js +51 -13
- package/lib/plugin/stepTimeout.js +4 -11
- package/lib/plugin/subtitles.js +4 -4
- package/lib/plugin/tryTo.js +1 -1
- package/lib/plugin/wdio.js +8 -10
- package/lib/recorder.js +142 -121
- package/lib/secret.js +1 -1
- package/lib/step.js +160 -144
- package/lib/store.js +6 -2
- package/lib/template/heal.js +2 -11
- package/lib/utils.js +224 -216
- package/lib/within.js +73 -55
- package/lib/workers.js +265 -261
- package/package.json +46 -47
- package/typings/index.d.ts +172 -184
- package/typings/promiseBasedTypes.d.ts +53 -516
- package/typings/types.d.ts +127 -587
- package/lib/cli.js +0 -256
- package/lib/helper/ExpectHelper.js +0 -391
- package/lib/helper/SoftExpectHelper.js +0 -381
- package/lib/mochaFactory.js +0 -113
- package/lib/scenario.js +0 -224
- package/lib/ui.js +0 -236
package/lib/recorder.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const debug = require('debug')('codeceptjs:recorder')
|
|
2
|
-
const promiseRetry = require('promise-retry')
|
|
3
|
-
const chalk = require('chalk')
|
|
4
|
-
const { printObjectProperties } = require('./utils')
|
|
5
|
-
const { log } = require('./output')
|
|
1
|
+
const debug = require('debug')('codeceptjs:recorder')
|
|
2
|
+
const promiseRetry = require('promise-retry')
|
|
3
|
+
const chalk = require('chalk')
|
|
4
|
+
const { printObjectProperties } = require('./utils')
|
|
5
|
+
const { log } = require('./output')
|
|
6
6
|
|
|
7
|
-
const MAX_TASKS = 100
|
|
7
|
+
const MAX_TASKS = 100
|
|
8
8
|
|
|
9
|
-
let promise
|
|
10
|
-
let running = false
|
|
11
|
-
let errFn
|
|
12
|
-
let queueId = 0
|
|
13
|
-
let sessionId = null
|
|
14
|
-
let asyncErr = null
|
|
15
|
-
let ignoredErrs = []
|
|
9
|
+
let promise
|
|
10
|
+
let running = false
|
|
11
|
+
let errFn
|
|
12
|
+
let queueId = 0
|
|
13
|
+
let sessionId = null
|
|
14
|
+
let asyncErr = null
|
|
15
|
+
let ignoredErrs = []
|
|
16
16
|
|
|
17
|
-
let tasks = []
|
|
18
|
-
let oldPromises = []
|
|
17
|
+
let tasks = []
|
|
18
|
+
let oldPromises = []
|
|
19
19
|
|
|
20
20
|
const defaultRetryOptions = {
|
|
21
21
|
retries: 0,
|
|
22
22
|
minTimeout: 150,
|
|
23
23
|
maxTimeout: 10000,
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Singleton object to record all test steps as promises and run them in chain.
|
|
@@ -29,7 +29,6 @@ const defaultRetryOptions = {
|
|
|
29
29
|
* @interface
|
|
30
30
|
*/
|
|
31
31
|
module.exports = {
|
|
32
|
-
|
|
33
32
|
/**
|
|
34
33
|
* @type {Array<Object<string, *>>}
|
|
35
34
|
* @inner
|
|
@@ -43,11 +42,11 @@ module.exports = {
|
|
|
43
42
|
* @inner
|
|
44
43
|
*/
|
|
45
44
|
start() {
|
|
46
|
-
debug('Starting recording promises')
|
|
47
|
-
running = true
|
|
48
|
-
asyncErr = null
|
|
49
|
-
errFn = null
|
|
50
|
-
this.reset()
|
|
45
|
+
debug('Starting recording promises')
|
|
46
|
+
running = true
|
|
47
|
+
asyncErr = null
|
|
48
|
+
errFn = null
|
|
49
|
+
this.reset()
|
|
51
50
|
},
|
|
52
51
|
|
|
53
52
|
/**
|
|
@@ -55,7 +54,7 @@ module.exports = {
|
|
|
55
54
|
* @inner
|
|
56
55
|
*/
|
|
57
56
|
isRunning() {
|
|
58
|
-
return running
|
|
57
|
+
return running
|
|
59
58
|
},
|
|
60
59
|
|
|
61
60
|
/**
|
|
@@ -64,7 +63,7 @@ module.exports = {
|
|
|
64
63
|
*/
|
|
65
64
|
startUnlessRunning() {
|
|
66
65
|
if (!this.isRunning()) {
|
|
67
|
-
this.start()
|
|
66
|
+
this.start()
|
|
68
67
|
}
|
|
69
68
|
},
|
|
70
69
|
|
|
@@ -76,7 +75,7 @@ module.exports = {
|
|
|
76
75
|
* @inner
|
|
77
76
|
*/
|
|
78
77
|
errHandler(fn) {
|
|
79
|
-
errFn = fn
|
|
78
|
+
errFn = fn
|
|
80
79
|
},
|
|
81
80
|
|
|
82
81
|
/**
|
|
@@ -87,16 +86,16 @@ module.exports = {
|
|
|
87
86
|
* @inner
|
|
88
87
|
*/
|
|
89
88
|
reset() {
|
|
90
|
-
if (promise && running) this.catch()
|
|
91
|
-
queueId
|
|
92
|
-
sessionId = null
|
|
93
|
-
asyncErr = null
|
|
94
|
-
log(`${currentQueue()} Starting recording promises`)
|
|
95
|
-
promise = Promise.resolve()
|
|
96
|
-
oldPromises = []
|
|
97
|
-
tasks = []
|
|
98
|
-
ignoredErrs = []
|
|
99
|
-
this.session.running = false
|
|
89
|
+
if (promise && running) this.catch()
|
|
90
|
+
queueId++
|
|
91
|
+
sessionId = null
|
|
92
|
+
asyncErr = null
|
|
93
|
+
log(`${currentQueue()} Starting recording promises`)
|
|
94
|
+
promise = Promise.resolve()
|
|
95
|
+
oldPromises = []
|
|
96
|
+
tasks = []
|
|
97
|
+
ignoredErrs = []
|
|
98
|
+
this.session.running = false
|
|
100
99
|
// reset this retries makes the retryFailedStep plugin won't work if there is Before/BeforeSuit block due to retries is undefined on Scenario
|
|
101
100
|
// this.retries = [];
|
|
102
101
|
},
|
|
@@ -123,12 +122,16 @@ module.exports = {
|
|
|
123
122
|
* @inner
|
|
124
123
|
*/
|
|
125
124
|
start(name) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
if (sessionId) {
|
|
126
|
+
debug(`${currentQueue()}Session already started as ${sessionId}`)
|
|
127
|
+
this.restore(sessionId)
|
|
128
|
+
}
|
|
129
|
+
debug(`${currentQueue()}Starting <${name}> session`)
|
|
130
|
+
tasks.push('--->')
|
|
131
|
+
oldPromises.push(promise)
|
|
132
|
+
this.running = true
|
|
133
|
+
sessionId = name
|
|
134
|
+
promise = Promise.resolve()
|
|
132
135
|
},
|
|
133
136
|
|
|
134
137
|
/**
|
|
@@ -136,12 +139,12 @@ module.exports = {
|
|
|
136
139
|
* @inner
|
|
137
140
|
*/
|
|
138
141
|
restore(name) {
|
|
139
|
-
tasks.push('<---')
|
|
140
|
-
debug(`${currentQueue()}Finalize <${name}> session`)
|
|
141
|
-
this.running = false
|
|
142
|
-
sessionId = null
|
|
143
|
-
this.catch(errFn)
|
|
144
|
-
promise = promise.then(() => oldPromises.pop())
|
|
142
|
+
tasks.push('<---')
|
|
143
|
+
debug(`${currentQueue()}Finalize <${name}> session`)
|
|
144
|
+
this.running = false
|
|
145
|
+
sessionId = null
|
|
146
|
+
this.catch(errFn)
|
|
147
|
+
promise = promise.then(() => oldPromises.pop())
|
|
145
148
|
},
|
|
146
149
|
|
|
147
150
|
/**
|
|
@@ -149,9 +152,8 @@ module.exports = {
|
|
|
149
152
|
* @inner
|
|
150
153
|
*/
|
|
151
154
|
catch(fn) {
|
|
152
|
-
promise = promise.catch(fn)
|
|
155
|
+
promise = promise.catch(fn)
|
|
153
156
|
},
|
|
154
|
-
|
|
155
157
|
},
|
|
156
158
|
|
|
157
159
|
/**
|
|
@@ -171,42 +173,47 @@ module.exports = {
|
|
|
171
173
|
*/
|
|
172
174
|
add(taskName, fn = undefined, force = false, retry = undefined, timeout = undefined) {
|
|
173
175
|
if (typeof taskName === 'function') {
|
|
174
|
-
fn = taskName
|
|
175
|
-
taskName = fn.toString()
|
|
176
|
-
if (retry === undefined) retry = false
|
|
176
|
+
fn = taskName
|
|
177
|
+
taskName = fn.toString()
|
|
178
|
+
if (retry === undefined) retry = false
|
|
177
179
|
}
|
|
178
|
-
if (retry === undefined) retry = true
|
|
180
|
+
if (retry === undefined) retry = true
|
|
179
181
|
if (!running && !force) {
|
|
180
|
-
return
|
|
182
|
+
return
|
|
181
183
|
}
|
|
182
|
-
tasks.push(taskName)
|
|
183
|
-
debug(chalk.gray(`${currentQueue()} Queued | ${taskName}`))
|
|
184
|
+
tasks.push(taskName)
|
|
185
|
+
debug(chalk.gray(`${currentQueue()} Queued | ${taskName}`))
|
|
184
186
|
|
|
185
|
-
return promise = Promise.resolve(promise).then(
|
|
187
|
+
return (promise = Promise.resolve(promise).then(res => {
|
|
186
188
|
// prefer options for non-conditional retries
|
|
187
|
-
const retryOpts = this.retries
|
|
189
|
+
const retryOpts = this.retries
|
|
190
|
+
.sort((r1, r2) => r1.when && !r2.when)
|
|
191
|
+
.slice(-1)
|
|
192
|
+
.pop()
|
|
188
193
|
// no retries or unnamed tasks
|
|
189
194
|
if (!retryOpts || !taskName || !retry) {
|
|
190
|
-
const [promise, timer] = getTimeoutPromise(timeout, taskName)
|
|
191
|
-
return Promise.race([promise, Promise.resolve(res).then(fn)]).finally(() => clearTimeout(timer))
|
|
195
|
+
const [promise, timer] = getTimeoutPromise(timeout, taskName)
|
|
196
|
+
return Promise.race([promise, Promise.resolve(res).then(fn)]).finally(() => clearTimeout(timer))
|
|
192
197
|
}
|
|
193
198
|
|
|
194
|
-
debug(`${currentQueue()} Running | ${taskName}`)
|
|
199
|
+
debug(`${currentQueue()} Running | ${taskName}`)
|
|
195
200
|
|
|
196
|
-
const retryRules = this.retries.slice().reverse()
|
|
201
|
+
const retryRules = this.retries.slice().reverse()
|
|
197
202
|
return promiseRetry(Object.assign(defaultRetryOptions, retryOpts), (retry, number) => {
|
|
198
|
-
if (number > 1) log(`${currentQueue()}Retrying... Attempt #${number}`)
|
|
199
|
-
const [promise, timer] = getTimeoutPromise(timeout, taskName)
|
|
200
|
-
return Promise.race([promise, Promise.resolve(res).then(fn)])
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
if (number > 1) log(`${currentQueue()}Retrying... Attempt #${number}`)
|
|
204
|
+
const [promise, timer] = getTimeoutPromise(timeout, taskName)
|
|
205
|
+
return Promise.race([promise, Promise.resolve(res).then(fn)])
|
|
206
|
+
.finally(() => clearTimeout(timer))
|
|
207
|
+
.catch(err => {
|
|
208
|
+
if (ignoredErrs.includes(err)) return
|
|
209
|
+
for (const retryObj of retryRules) {
|
|
210
|
+
if (!retryObj.when) return retry(err)
|
|
211
|
+
if (retryObj.when && retryObj.when(err)) return retry(err)
|
|
212
|
+
}
|
|
213
|
+
throw err
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
}))
|
|
210
217
|
},
|
|
211
218
|
|
|
212
219
|
/**
|
|
@@ -215,15 +222,15 @@ module.exports = {
|
|
|
215
222
|
* @inner
|
|
216
223
|
*/
|
|
217
224
|
retry(opts) {
|
|
218
|
-
if (!promise) return
|
|
225
|
+
if (!promise) return
|
|
219
226
|
|
|
220
227
|
if (opts === null) {
|
|
221
|
-
opts = {}
|
|
228
|
+
opts = {}
|
|
222
229
|
}
|
|
223
230
|
if (Number.isInteger(opts)) {
|
|
224
|
-
opts = { retries: opts }
|
|
231
|
+
opts = { retries: opts }
|
|
225
232
|
}
|
|
226
|
-
return this.add(() => this.retries.push(opts))
|
|
233
|
+
return this.add(() => this.retries.push(opts))
|
|
227
234
|
},
|
|
228
235
|
|
|
229
236
|
/**
|
|
@@ -232,20 +239,25 @@ module.exports = {
|
|
|
232
239
|
* @inner
|
|
233
240
|
*/
|
|
234
241
|
catch(customErrFn) {
|
|
235
|
-
const fnDescription = customErrFn
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
const fnDescription = customErrFn
|
|
243
|
+
?.toString()
|
|
244
|
+
?.replace(/\s{2,}/g, ' ')
|
|
245
|
+
.replace(/\n/g, ' ')
|
|
246
|
+
?.slice(0, 50)
|
|
247
|
+
debug(chalk.gray(`${currentQueue()} Queued | catch with error handler ${fnDescription || ''}`))
|
|
248
|
+
return (promise = promise.catch(err => {
|
|
249
|
+
log(`${currentQueue()}Error | ${err} ${fnDescription}...`)
|
|
250
|
+
if (!(err instanceof Error)) {
|
|
251
|
+
// strange things may happen
|
|
252
|
+
err = new Error(`[Wrapped Error] ${printObjectProperties(err)}`) // we should be prepared for them
|
|
241
253
|
}
|
|
242
254
|
if (customErrFn) {
|
|
243
|
-
customErrFn(err)
|
|
255
|
+
customErrFn(err)
|
|
244
256
|
} else if (errFn) {
|
|
245
|
-
errFn(err)
|
|
257
|
+
errFn(err)
|
|
246
258
|
}
|
|
247
|
-
this.stop()
|
|
248
|
-
})
|
|
259
|
+
this.stop()
|
|
260
|
+
}))
|
|
249
261
|
},
|
|
250
262
|
|
|
251
263
|
/**
|
|
@@ -254,17 +266,22 @@ module.exports = {
|
|
|
254
266
|
* @inner
|
|
255
267
|
*/
|
|
256
268
|
catchWithoutStop(customErrFn) {
|
|
257
|
-
const fnDescription = customErrFn
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
269
|
+
const fnDescription = customErrFn
|
|
270
|
+
?.toString()
|
|
271
|
+
?.replace(/\s{2,}/g, ' ')
|
|
272
|
+
.replace(/\n/g, ' ')
|
|
273
|
+
?.slice(0, 50)
|
|
274
|
+
return (promise = promise.catch(err => {
|
|
275
|
+
if (ignoredErrs.includes(err)) return // already caught
|
|
276
|
+
log(`${currentQueue()} Error (Non-Terminated) | ${err} | ${fnDescription || ''}...`)
|
|
277
|
+
if (!(err instanceof Error)) {
|
|
278
|
+
// strange things may happen
|
|
279
|
+
err = new Error(`[Wrapped Error] ${JSON.stringify(err)}`) // we should be prepared for them
|
|
263
280
|
}
|
|
264
281
|
if (customErrFn) {
|
|
265
|
-
return customErrFn(err)
|
|
282
|
+
return customErrFn(err)
|
|
266
283
|
}
|
|
267
|
-
})
|
|
284
|
+
}))
|
|
268
285
|
},
|
|
269
286
|
|
|
270
287
|
/**
|
|
@@ -276,15 +293,15 @@ module.exports = {
|
|
|
276
293
|
*/
|
|
277
294
|
|
|
278
295
|
throw(err) {
|
|
279
|
-
if (ignoredErrs.includes(err)) return promise
|
|
296
|
+
if (ignoredErrs.includes(err)) return promise // already caught
|
|
280
297
|
return this.add(`throw error: ${err.message}`, () => {
|
|
281
|
-
if (ignoredErrs.includes(err)) return
|
|
282
|
-
throw err
|
|
283
|
-
})
|
|
298
|
+
if (ignoredErrs.includes(err)) return // already caught
|
|
299
|
+
throw err
|
|
300
|
+
})
|
|
284
301
|
},
|
|
285
302
|
|
|
286
303
|
ignoreErr(err) {
|
|
287
|
-
ignoredErrs.push(err)
|
|
304
|
+
ignoredErrs.push(err)
|
|
288
305
|
},
|
|
289
306
|
|
|
290
307
|
/**
|
|
@@ -293,7 +310,7 @@ module.exports = {
|
|
|
293
310
|
*/
|
|
294
311
|
saveFirstAsyncError(err) {
|
|
295
312
|
if (asyncErr === null) {
|
|
296
|
-
asyncErr = err
|
|
313
|
+
asyncErr = err
|
|
297
314
|
}
|
|
298
315
|
},
|
|
299
316
|
|
|
@@ -302,7 +319,7 @@ module.exports = {
|
|
|
302
319
|
* @inner
|
|
303
320
|
*/
|
|
304
321
|
getAsyncErr() {
|
|
305
|
-
return asyncErr
|
|
322
|
+
return asyncErr
|
|
306
323
|
},
|
|
307
324
|
|
|
308
325
|
/**
|
|
@@ -310,7 +327,7 @@ module.exports = {
|
|
|
310
327
|
* @inner
|
|
311
328
|
*/
|
|
312
329
|
cleanAsyncErr() {
|
|
313
|
-
asyncErr = null
|
|
330
|
+
asyncErr = null
|
|
314
331
|
},
|
|
315
332
|
|
|
316
333
|
/**
|
|
@@ -319,9 +336,9 @@ module.exports = {
|
|
|
319
336
|
* @inner
|
|
320
337
|
*/
|
|
321
338
|
stop() {
|
|
322
|
-
debug(this.toString())
|
|
323
|
-
log(`${currentQueue()} Stopping recording promises`)
|
|
324
|
-
running = false
|
|
339
|
+
debug(this.toString())
|
|
340
|
+
log(`${currentQueue()} Stopping recording promises`)
|
|
341
|
+
running = false
|
|
325
342
|
},
|
|
326
343
|
|
|
327
344
|
/**
|
|
@@ -332,7 +349,7 @@ module.exports = {
|
|
|
332
349
|
* @inner
|
|
333
350
|
*/
|
|
334
351
|
promise() {
|
|
335
|
-
return promise
|
|
352
|
+
return promise
|
|
336
353
|
},
|
|
337
354
|
|
|
338
355
|
/**
|
|
@@ -341,7 +358,7 @@ module.exports = {
|
|
|
341
358
|
* @inner
|
|
342
359
|
*/
|
|
343
360
|
scheduled() {
|
|
344
|
-
return tasks.slice(-MAX_TASKS).join('\n')
|
|
361
|
+
return tasks.slice(-MAX_TASKS).join('\n')
|
|
345
362
|
},
|
|
346
363
|
|
|
347
364
|
/**
|
|
@@ -350,7 +367,7 @@ module.exports = {
|
|
|
350
367
|
* @inner
|
|
351
368
|
*/
|
|
352
369
|
getQueueId() {
|
|
353
|
-
return queueId
|
|
370
|
+
return queueId
|
|
354
371
|
},
|
|
355
372
|
|
|
356
373
|
/**
|
|
@@ -359,21 +376,25 @@ module.exports = {
|
|
|
359
376
|
* @inner
|
|
360
377
|
*/
|
|
361
378
|
toString() {
|
|
362
|
-
return `Queue: ${currentQueue()}\n\nTasks: ${this.scheduled()}
|
|
379
|
+
return `Queue: ${currentQueue()}\n\nTasks: ${this.scheduled()}`
|
|
363
380
|
},
|
|
364
|
-
|
|
365
|
-
};
|
|
381
|
+
}
|
|
366
382
|
|
|
367
383
|
function getTimeoutPromise(timeoutMs, taskName) {
|
|
368
|
-
let timer
|
|
369
|
-
if (timeoutMs) debug(`Timing out in ${timeoutMs}ms`)
|
|
370
|
-
return [
|
|
371
|
-
|
|
372
|
-
|
|
384
|
+
let timer
|
|
385
|
+
if (timeoutMs) debug(`Timing out in ${timeoutMs}ms`)
|
|
386
|
+
return [
|
|
387
|
+
new Promise((done, reject) => {
|
|
388
|
+
timer = setTimeout(() => {
|
|
389
|
+
reject(new Error(`Action ${taskName} was interrupted on step timeout ${timeoutMs}ms`))
|
|
390
|
+
}, timeoutMs || 2e9)
|
|
391
|
+
}),
|
|
392
|
+
timer,
|
|
393
|
+
]
|
|
373
394
|
}
|
|
374
395
|
|
|
375
396
|
function currentQueue() {
|
|
376
|
-
let session = ''
|
|
377
|
-
if (sessionId) session = `<${sessionId}>
|
|
378
|
-
return `[${queueId}] ${session}
|
|
397
|
+
let session = ''
|
|
398
|
+
if (sessionId) session = `<${sessionId}> `
|
|
399
|
+
return `[${queueId}] ${session}`
|
|
379
400
|
}
|
package/lib/secret.js
CHANGED
|
@@ -37,7 +37,7 @@ function secretObject(obj, fieldsToHide = []) {
|
|
|
37
37
|
if (prop === 'toString') {
|
|
38
38
|
return function () {
|
|
39
39
|
const maskedObject = deepClone(obj);
|
|
40
|
-
fieldsToHide.forEach(f => maskedObject[f] = maskedString);
|
|
40
|
+
fieldsToHide.forEach(f => (maskedObject[f] = maskedString));
|
|
41
41
|
return JSON.stringify(maskedObject);
|
|
42
42
|
};
|
|
43
43
|
}
|