Skip to content
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

fix(expect)!: loosen toMatchObject and objectContaining for Proxy.get #6675

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Oct 10, 2024

Description

I'm not sure if this behavior is the best, but I'm creating a PR to test a few things.
Technically this is a breaking change since people might be using negating expect(someProxy).not.toMatchObject({ ... }) to assert proxy keys not being there.

pros

  • convenient for testing Proxy.get
  • toMatchObject/objectContaining already allows testing non-enumerable properties (e.g. Error.cause)

cons

  • Proxy.get won't give better diff since non-enumerable
  • breaking change
  • no jest compat

todo

  • docs to explain what type of properties (enumerable vs. non-enumerable) are considered for toEqual, toMatchObject, etc... also diff format

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Oct 10, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f0ca9a3
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/6707487c57cccd0008c90756
😎 Deploy Preview https://deploy-preview-6675--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hi-ogawa hi-ogawa marked this pull request as ready for review October 10, 2024 05:16
@sheremet-va sheremet-va added this to the 3.0.0 milestone Oct 12, 2024
@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Dec 6, 2024

Closing as par #6672 (comment)

@hi-ogawa hi-ogawa closed this Dec 6, 2024
@hi-ogawa hi-ogawa deleted the fix-loosen-toMatchObject-actual-property branch December 6, 2024 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toMatchObject doesn't work well with Proxy objects
2 participants