codeceptjs 4.0.1-beta.1 → 4.0.1-beta.3
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/container.js +13 -23
- package/lib/helper/REST.js +2 -1
- package/package.json +1 -1
package/lib/container.js
CHANGED
|
@@ -110,6 +110,9 @@ class Container {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// Wait for all async helpers to finish loading and populate the actor with helper methods
|
|
114
|
+
await asyncHelperPromise
|
|
115
|
+
|
|
113
116
|
if (opts && opts.ai) ai.enable(config.ai) // enable AI Assistant
|
|
114
117
|
if (config.gherkin) await loadGherkinStepsAsync(config.gherkin.steps || [])
|
|
115
118
|
if (opts && typeof opts.timeouts === 'boolean') store.timeouts = opts.timeouts
|
|
@@ -202,15 +205,6 @@ class Container {
|
|
|
202
205
|
static append(newContainer) {
|
|
203
206
|
container = deepMerge(container, newContainer)
|
|
204
207
|
|
|
205
|
-
// If new helpers are added, set the helpers property on them
|
|
206
|
-
if (newContainer.helpers) {
|
|
207
|
-
for (const name in newContainer.helpers) {
|
|
208
|
-
if (container.helpers[name] && typeof container.helpers[name] === 'object') {
|
|
209
|
-
container.helpers[name].helpers = container.helpers
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
208
|
// If new support objects are added, update the proxy support
|
|
215
209
|
if (newContainer.support) {
|
|
216
210
|
const newProxySupport = createSupportObjects(newContainer.support)
|
|
@@ -301,7 +295,7 @@ async function createHelpers(config) {
|
|
|
301
295
|
if (!HelperClass) {
|
|
302
296
|
const helperResult = requireHelperFromModule(helperName, config)
|
|
303
297
|
if (helperResult instanceof Promise) {
|
|
304
|
-
// Handle async ESM loading
|
|
298
|
+
// Handle async ESM loading - create placeholder
|
|
305
299
|
helpers[helperName] = {}
|
|
306
300
|
asyncHelperPromise = asyncHelperPromise
|
|
307
301
|
.then(() => helperResult)
|
|
@@ -320,8 +314,7 @@ async function createHelpers(config) {
|
|
|
320
314
|
|
|
321
315
|
checkHelperRequirements(ResolvedHelperClass)
|
|
322
316
|
helpers[helperName] = new ResolvedHelperClass(config[helperName])
|
|
323
|
-
|
|
324
|
-
debug(`helper ${helperName} async initialized`)
|
|
317
|
+
debug(`helper ${helperName} async loaded`)
|
|
325
318
|
})
|
|
326
319
|
continue
|
|
327
320
|
} else {
|
|
@@ -341,9 +334,8 @@ async function createHelpers(config) {
|
|
|
341
334
|
throw new Error(`Helper class from module '${helperName}' is not a class. Use CJS async module syntax.`)
|
|
342
335
|
}
|
|
343
336
|
|
|
344
|
-
debug(`helper ${helperName} async initialized`)
|
|
345
|
-
|
|
346
337
|
helpers[helperName] = new ResolvedHelperClass(config[helperName])
|
|
338
|
+
debug(`helper ${helperName} async CJS loaded`)
|
|
347
339
|
})
|
|
348
340
|
|
|
349
341
|
continue
|
|
@@ -358,19 +350,17 @@ async function createHelpers(config) {
|
|
|
358
350
|
}
|
|
359
351
|
}
|
|
360
352
|
|
|
361
|
-
//
|
|
362
|
-
for (const name in helpers) {
|
|
363
|
-
if (helpers[name] && typeof helpers[name] === 'object') {
|
|
364
|
-
helpers[name].helpers = helpers
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// Wait for async helpers and call _init
|
|
353
|
+
// Wait for all async helpers to be fully loaded
|
|
369
354
|
await asyncHelperPromise
|
|
370
355
|
|
|
356
|
+
// Call _init on all helpers after they're all loaded
|
|
371
357
|
for (const name in helpers) {
|
|
372
|
-
if (helpers[name]._init)
|
|
358
|
+
if (helpers[name]._init) {
|
|
359
|
+
await helpers[name]._init()
|
|
360
|
+
debug(`helper ${name} _init() called`)
|
|
361
|
+
}
|
|
373
362
|
}
|
|
363
|
+
|
|
374
364
|
return helpers
|
|
375
365
|
}
|
|
376
366
|
|
package/lib/helper/REST.js
CHANGED
|
@@ -468,7 +468,8 @@ class REST extends Helper {
|
|
|
468
468
|
export { REST as default }
|
|
469
469
|
|
|
470
470
|
function curlize(request) {
|
|
471
|
-
|
|
471
|
+
// Guard access to nested properties safely in case request.data is undefined
|
|
472
|
+
if ((request.data?.constructor?.name || '').toLowerCase() === 'formdata') return 'cURL is not printed as the request body is not a JSON'
|
|
472
473
|
let curl = `curl --location --request ${request.method ? request.method.toUpperCase() : 'GET'} ${request.baseURL} `.replace("'", '')
|
|
473
474
|
|
|
474
475
|
if (request.headers) {
|