You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('should be able to use multiple times',()=>{test('minimal reproduction',()=>{constmatcher=expect.objectContaining({id: '2'});expect({id: '1',prop: 'prop1'}).not.toEqual(matcher);expect({id: '2'}).toEqual(matcher);});test('example use case',()=>{// Check that the items received are what we expect them to be.// Note: The order of the items is not defined.constitemsFromDb=[{id: '1',prop: 'prop1',},{id: '2',},];expect(itemsFromDb).toEqual(expect.arrayContaining([expect.objectContaining({id: '1'}),expect.objectContaining({id: '2'}),]),);expect(itemsFromDb.length).toBe(2);/* * expect(received).toEqual(expected) // deep equality * * Expected: ArrayContaining [ObjectContaining {"id": "1"}, ObjectContaining {"id": "2", "prop": "prop1"}] * ~~~~~~~~~~~~~~~ * Received: [{"id": "1", "prop": "prop1"}, {"id": "2"}] */});});
The first test case demonstrates the bare-bones issue, the second shows how this pattern can arise in normal code.
Expected behavior
ObjectContaining should work within ArrayContaining.
Actual behavior
If an ObjectContaining matcher instance is invoked after having failed before (see the first test), the second invocation expects excess properties from the first invocation to be present.
Version
30.0.0-alpha.6
Steps to reproduce
The first test case demonstrates the bare-bones issue, the second shows how this pattern can arise in normal code.
Expected behavior
ObjectContaining
should work withinArrayContaining
.Actual behavior
If an
ObjectContaining
matcher instance is invoked after having failed before (see the first test), the second invocation expects excess properties from the first invocation to be present.Additional context
This broke in #15038.
Environment
The text was updated successfully, but these errors were encountered: