Skip to content

Conversation

@kobenguyent
Copy link
Collaborator

Motivation/Description of the PR

  • Description of this PR, which problem it solves
  • Resolves #issueId (if applicable).

Applicable helpers:

  • Playwright
  • Puppeteer
  • WebDriver
  • REST
  • FileHelper
  • Appium
  • TestCafe

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • coverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • stepTimeout
  • wdio
  • subtitles

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 🧹 Chore
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

…rors

The config listener was capturing a static snapshot of helpers at
initialization time, which could contain empty placeholder objects
during async helper loading. This caused 'Cannot read properties of
undefined (reading name)' errors when tests tried to access helper
properties.

Changes:
- Move helpers retrieval inside event handler to get runtime instances
- Add guard clause to check helper validity before accessing properties
- Ensures we always get fully initialized helper instances, not placeholders

Fixes issue where actor I was empty {} and helper.constructor.name
threw undefined errors during Scenario execution.
The Helper base class from @codeceptjs/helper sets both this.config (raw user config)
and this.options (validated/merged config with defaults). Helpers should consistently
use this.options to access configuration values.

Fixed helpers to use this.options for onRequest/onResponse callbacks:
- REST helper: Fixed onRequest and onResponse to use this.options
- GraphQL helper: Fixed onRequest and onResponse to use this.options
- Playwright helper: Fixed onResponse to use this.options
- JSONResponse helper: Fixed accessing request helper's options.onResponse

Updated tests to match:
- JSONResponse_test.js: Changed restHelper.config to restHelper.options
- JSONResponse_test.js: Made beforeEach async and await Container.create()
- Playwright_test.js: Changed I.config to I.options
- JSONResponse.js: Added named export for test compatibility

This fixes the error: 'Cannot read properties of undefined (reading "name")'
which occurred because JSONResponse tried to access this.helpers.REST.config.onResponse
but REST helper stores callbacks in this.options, not this.config.

All 488 unit tests passing.
…nResponse

The issue was that _setConfig() overwrites this.options entirely, losing any defaults
that were set before it was called. This caused this.options.onResponse to be undefined
instead of null when not configured by the user.

Fixed by:
- REST: Merge config with defaults after _setConfig() call
- GraphQL: Add onRequest/onResponse to defaults (was missing)
- Playwright: Add onResponse to defaults (was missing)

This ensures that helpers always have these properties defined, even if set to null,
preventing 'Cannot read properties of undefined' errors when JSONResponse or other
code tries to access them.

All 488 unit tests passing.
- Fixed actor not being populated with helper methods
- Fixed circular dependency in actor.js
- Moved actor creation timing to allow proper callback registration
- Fixed helpers to use this.options consistently instead of this.config
- Fixed helpers to merge defaults after _setConfig()
- Fixed container proxy getOwnPropertyDescriptor for destructuring support
- Changed createHelpers to defer await for proper callback accumulation
- Fixed actor to use existing instance when available
- Added container.append() when actor reference changes
- Ensures custom PageObject methods are properly added to actor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants