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

feat(expect): add ArrayOf asymmetric matcher #15567

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

icholy
Copy link

@icholy icholy commented Apr 6, 2025

Summary

This PR adds a new asymmetric matcher expect.arrayOf(sample) and its inverse expect.not.arrayOf(sample). This matcher simplifies assertions on arrays by validating that all elements match a provided condition. I don't think that not.arrayOf is particularly useful, but I included it for the sake of symmetry.

Example:

expect(value).toMatchObject({
  items: expect.arrayOf(
    expect.objectContaining({
      id: expect.any(String),
    }),
  ),
});

Test plan

I've added tests which are comparable to the other asymmetric matcher tests.

Copy link

netlify bot commented Apr 6, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1a7df6b
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/67f2aedc7ae557000812f2fc
😎 Deploy Preview https://deploy-preview-15567--jestjs.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.

Copy link

netlify bot commented Apr 6, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8b6d7d0
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/67f2b0f6354eba000844cd13
😎 Deploy Preview https://deploy-preview-15567--jestjs.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.

@icholy icholy force-pushed the main branch 2 times, most recently from 9d7405a to a77ad22 Compare April 6, 2025 16:50
@icholy
Copy link
Author

icholy commented Apr 6, 2025

I'm not seeing my documentation changes in the preview link. Did I miss a build step?

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.

1 participant