v1.2.0 - Vitest, plus some new matchers
This minor release adds Vitest support, and some new matchers.
Vitest
This release adds support for Vitest, by adding an explicit dependency on jest-matcher-utils
for utilities provided by Jest but not Vitest.
See the README for the setup guide.
New matchers
expect.typeOf
This asymmetric matcher checks that a given value has a given typeof
.
expect(getPost()).toEqual({ title: expect.typeOf("string") })
expect.arrayContainingOnly
This asymmetric matcher checks that a given array only contains values from an expected array.
Values can be duplicate or omitted, but all values present must match.
expect([1, 2]).toEqual(expect.arrayContainingOnly([1, 2, 3])) // passes
expect([1, 2, 3]).toEqual(expect.arrayContainingOnly([1, 2])) // fails
This is different to expect.arrayContaining
, which checks that all expected values are present and allows for other values.
expect([1, 2]).toEqual(expect.arrayContaining([1,2,3])) // fails
expect([1, 2, 3]).toEqual(expect.arrayContaining([1, 2])) // passes
expect.objectContainingOnly
This asymmetric matcher checks that a given object only contains matching keys from an expected object.
Keys can be omitted, but keys present must match.
expect({ a: 1 }).toEqual(expect.objectContainingOnly({ a: 1, b: 2 })) // passes
expect({ a: 1, b: 2 }).toEqual(expect.objectContainingOnly({ a: 1 })) // fails
This is different to expect.objectContaining
, which checks that all expected keys are present and allows for other keys.
expect({ a: 1 }).toEqual(expect.objectContaining({ a: 1, b: 2 })) // fails
expect({ a: 1, b: 2 }).toEqual(expect.objectContaining({ a: 1 })) // passes
What's Changed
- Add asymmetric expect.typeOf matcher by @EskiMojo14 in #4
- Add vitest support by @EskiMojo14 in #2
- Add arrayContainingOnly and objectContainingOnly by @EskiMojo14 in #5
Full Changelog: v1.1.1...v1.2.0