vitest icon indicating copy to clipboard operation
vitest copied to clipboard

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

Open hi-ogawa opened this issue 1 year ago • 1 comments

Description

  • closes https://github.com/vitest-dev/vitest/issues/6672

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:

  • [x] 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

  • [x] 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:.

hi-ogawa avatar Oct 10 '24 03:10 hi-ogawa

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
Latest commit f0ca9a31132ef3df3b92e801ff07610ed82212e7
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.

netlify[bot] avatar Oct 10 '24 03:10 netlify[bot]

Closing as par https://github.com/vitest-dev/vitest/issues/6672#issuecomment-2521919672

hi-ogawa avatar Dec 06 '24 01:12 hi-ogawa