https://github.com/nerdo/jest-extended
nerdo's custom jest matchers
https://github.com/nerdo/jest-extended
Last synced: 12 months ago
JSON representation
nerdo's custom jest matchers
- Host: GitHub
- URL: https://github.com/nerdo/jest-extended
- Owner: nerdo
- License: mit
- Created: 2020-07-12T21:08:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-12T21:31:05.000Z (about 6 years ago)
- Last Synced: 2025-06-16T20:47:52.724Z (about 1 year ago)
- Language: TypeScript
- Size: 113 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @nerdo/jest-extended
> nerdo's custom jest matchers
## Install it
```bash
npm install --save-dev @nerdo/jest-extended
```
## Set it up
```
// jest.config.js
module.exports = {
setupFilesAfterEnv: [
'@nerdo/jest-extended'
]
}
```
If you are using TypeScript and your editor does not recognize the new matchers, create a `global.d.ts` file in your project.
```
// global.d.ts
import '@nerdo/jest-extended'
```
If it _still_ is not working, you may also need to create a `tsconfig.json` with an empty object `{}` defined as the contents.
## Asymmetric Matchers
### expect.arrayExclusivelyContaining(array)
expect.arrayExclusivelyContaining(array) matches a received array which contains all of the elements in the expected array AND contains the same number of elements.
It usage is exactly the same as [jest's built-in expect.arrayContaining(array)](https://jestjs.io/docs/en/expect#expectarraycontainingarray).
### expect.objectExclusivelyContaining(object)
expect.objectExclusivelyContaining(object) matches a received object which contains all of the keys and values in the expected object AND contains the same number of properties.
It usage is exactly the same as [jest's built-in expect.objectContaining(object)](https://jestjs.io/docs/en/expect#expectobjectcontainingobject)