Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/matchers/mock/toBeRequestedWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,21 @@ const headersMatcher = (
*
* Jest and Jasmine support special matchers like `jasmine.objectContaining`, `expect.arrayContaining`, etc.
*
* All these kind of objects have `sample` and `asymmetricMatch` function in __proto__
* `expect.objectContaining({ foo: 'bar })` -> `{ sample: { foo: 'bar' }, __proto__: asymmetricMatch() {} }`
* All these kind of objects have `sample` and `asymmetricMatch` function in their prototype
* `expect.objectContaining({ foo: 'bar })` -> `{ sample: { foo: 'bar' }, [prototype]: asymmetricMatch() {} }`
*
* jasmine.any and jasmine.anything don't have `sample` property
* @param filter
*/
const isMatcher = (filter: unknown) => {
const proto = Object.getPrototypeOf(filter)
return (
typeof filter === 'object' &&
filter !== null &&
'__proto__' in filter &&
typeof filter.__proto__ === 'object' &&
filter.__proto__ &&
'asymmetricMatch' in filter.__proto__ &&
typeof filter.__proto__.asymmetricMatch === 'function'
typeof proto === 'object' &&
proto &&
'asymmetricMatch' in proto &&
typeof proto.asymmetricMatch === 'function'
)
}

Expand Down