-
-
Notifications
You must be signed in to change notification settings - Fork 752
fix bugs #5300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kobenguyent
wants to merge
8
commits into
4.x
Choose a base branch
from
fix-bug
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix bugs #5300
+146
−129
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation/Description of the PR
Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test)