MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / createSupportObjects

Function createSupportObjects

lib/container.js:531–683  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

529}
530
531function createSupportObjects(config) {
532 const asyncWrapper = function (f) {
533 return function () {
534 return f.apply(this, arguments).catch(e => {
535 recorder.saveFirstAsyncError(e)
536 throw e
537 })
538 }
539 }
540
541 function lazyLoad(name) {
542 return new Proxy(
543 {},
544 {
545 get(target, prop) {
546 // behavr like array or
547 if (prop === 'length') return Object.keys(config).length
548 if (prop === Symbol.iterator) {
549 return function* () {
550 for (let i = 0; i < Object.keys(config).length; i++) {
551 yield target[i]
552 }
553 }
554 }
555
556 // load actual name from vocabulary
557 if (container.translation && container.translation.I && name === 'I') {
558 // Use translated name for I
559 const actualName = container.translation.I
560 if (actualName !== 'I') {
561 name = actualName
562 }
563 }
564
565 if (name === 'I') {
566 if (!container.support.I) {
567 // Actor will be created during container.create()
568 return undefined
569 }
570 methodsOfObject(container.support.I)
571 return container.support.I[prop]
572 }
573
574 if (!container.support[name] && typeof config[name] === 'object') {
575 container.support[name] = config[name]
576 }
577
578 if (!container.support[name]) {
579 // Cannot load object synchronously in proxy getter
580 // Return undefined and log warning - object should be pre-loaded during container creation
581 debug(`Support object ${name} not pre-loaded, returning undefined`)
582 return undefined
583 }
584
585 const currentObject = container.support[name]
586 let currentValue = currentObject[prop]
587
588 if (isFunction(currentValue) || isAsyncFunction(currentValue)) {

Callers 3

createMethod · 0.85
appendMethod · 0.85
clearMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected