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

Method _init

lib/helper/Playwright.js:491–540  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

489 }
490
491 async _init() {
492 // Load playwright dynamically with fallback
493 if (!playwright) {
494 try {
495 playwright = await import('playwright')
496 playwright = playwright.default || playwright
497 } catch (e) {
498 try {
499 playwright = await import('playwright-core')
500 playwright = playwright.default || playwright
501 } catch (e2) {
502 throw new Error('Neither playwright nor playwright-core could be loaded. Please install one of them.')
503 }
504 }
505 }
506
507 // register an internal selector engine for reading value property of elements in a selector
508 try {
509 // Always wrap in try-catch since selectors might be registered globally across workers
510 // Check global flag to avoid re-registration in worker processes
511 if (!defaultSelectorEnginesInitialized) {
512 try {
513 await playwright.selectors.register('__value', createValueEngine)
514 await playwright.selectors.register('__disabled', createDisabledEngine)
515 defaultSelectorEnginesInitialized = true
516 defaultSelectorEnginesInitialized = true
517 } catch (e) {
518 if (!e.message.includes('already registered')) {
519 throw e
520 }
521 // Selector already registered globally by another worker
522 defaultSelectorEnginesInitialized = true
523 defaultSelectorEnginesInitialized = true
524 }
525 } else {
526 // Selectors already registered in a worker, skip
527 defaultSelectorEnginesInitialized = true
528 this.debugSection('Init', 'Default selector engines already registered globally, skipping')
529 }
530 if (process.env.testIdAttribute) {
531 try {
532 await playwright.selectors.setTestIdAttribute(process.env.testIdAttribute)
533 } catch (e) {
534 // Ignore if already set
535 }
536 }
537 } catch (e) {
538 console.warn(e)
539 }
540 }
541
542 _beforeSuite() {
543 // Skip browser start in dry-run mode (used by check command)

Callers 1

_startBrowserMethod · 0.95

Calls 1

includesMethod · 0.80

Tested by

no test coverage detected