Skip to content

Add matcher for object arrays - #40

Open
patrickschilder wants to merge 4 commits into
mainfrom
add-object-in-array-matcher
Open

patrickschilder wants to merge 4 commits into
mainfrom
add-object-in-array-matcher

Conversation

@patrickschilder

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new object-array matcher, toContainObjectMatching, to the Playwright Expectly matcher suite, along with documentation and tests to validate partial-object containment semantics and the allowMultiple option.

Changes:

  • Introduces toContainObjectMatching matcher implementation for object arrays (supports partial matches via expect.objectContaining and an allowMultiple option).
  • Adds comprehensive test coverage for matching, negation, and typed-array usage.
  • Updates public matcher typings, docs, and versioning artifacts (changeset + lockfile/package updates).

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/playwright-expectly/tests/expectly-object-array.spec.ts Adds new test suites covering toContainObjectMatching, including typed-object scenarios.
packages/playwright-expectly/src/types/matcher-types.ts Exposes the new matcher in the global matcher type definitions.
packages/playwright-expectly/src/expectly-object-array.ts Implements the toContainObjectMatching matcher in the object-array matcher set.
docs/OBJECT_ARRAY_MATCHERS.md Documents toContainObjectMatching usage and the allowMultiple option.
.changeset/clever-beds-brush.md Declares a minor release for the new matcher.
package.json Adds an allowScripts entry.
package-lock.json Updates workspace package versions and removes extraneous entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/playwright-expectly/src/types/matcher-types.ts
Comment thread packages/playwright-expectly/tests/expectly-object-array.spec.ts Outdated
Comment thread packages/playwright-expectly/src/expectly-object-array.ts
Comment thread package.json
"engines": {
"node": "^22.18.0 || >=24.11.0"
},
"allowScripts": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required for new node versions and using packages which need to run scripts. Otherwise npm install will fail

const assertionName = "toContainObjectMatching";
const allowMultiple = options?.allowMultiple ?? true;

const expectedMatcher = baseExpect.objectContaining(expected);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about an object with nested objects/arrays?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we only allow plain objects? So toContainPlainObjectMatching? ;)

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.

3 participants