Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] 3.7.3 I.seeResponseContainsJson not working #5081

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

Merged
kobenguyent merged 2 commits into 3.x from copilot/fix-4993
Aug 20, 2025
Merged

Conversation

Copy link
Contributor

@Copilot Copilot AI commented Aug 20, 2025
edited
Loading

Fixed the issue with I.seeResponseContainsJson() not working correctly in version 3.7.3. The problem was in the _assertContains method when dealing with arrays.

Root Cause:

  • The _assertContains method was treating arrays as objects and doing index-by-index comparison instead of checking if each expected array element had a corresponding match in the actual array
  • This caused it to only check the first element in arrays rather than searching through all elements

Solution:

  • Modified the _assertContains method to properly handle array matching by detecting when expected values are arrays and implementing proper element-by-element matching logic
  • When the expected value is an array, the method now searches through all elements in the actual array to find matches for each expected element
  • Improved error messages to be more descriptive when matches are not found

Changes Made:

  • Enhanced _assertContains method in lib/helper/JSONResponse.js to handle arrays correctly
  • Updated test expectations in test/helper/JSONResponse_test.js to match new error messages
  • Fixed unrelated test issue with callback test using wrong parameter (assert vs expect)
  • Validated fix with comprehensive tests covering various scenarios
  • Ensured all existing tests still pass

Validation:

  • All unit tests pass (344/344)
  • JSONResponse-specific tests pass (16/16)
  • Created comprehensive test scenarios to verify the fix works for:
    • Array properties within objects (finding elements by position)
    • Response data that is itself an array
    • Multiple element matching
    • Proper failure cases with clear error messages

The fix now correctly searches through all array elements for matches instead of stopping at the first element, restoring the behavior that worked in version 3.6.5.

Fixes #4993.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@kobenguyent kobenguyent Awaiting requested review from kobenguyent

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3.7.3 I.seeResponseContainsJson not working

AltStyle によって変換されたページ (->オリジナル) /