Skip to content

Commit

Permalink
fix: check for asymmetricMatch before accessing
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 5, 2022
1 parent 40862a2 commit 757199a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/integrations/chai/jest-expect.ts
Expand Up @@ -548,7 +548,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
)
}

if (typeof (expected as any).asymmetricMatch === 'function') {
if ('asymmetricMatch' in expected && typeof (expected as any).asymmetricMatch === 'function') {
const matcher = expected as any as AsymmetricMatcher<any>
return this.assert(
thrown && matcher.asymmetricMatch(thrown),
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/integrations/chai/jest-utils.ts
Expand Up @@ -38,7 +38,7 @@ export function equals(
const functionToString = Function.prototype.toString

export function isAsymmetric(obj: any) {
return !!obj && isA('Function', obj.asymmetricMatch)
return !!obj && 'asymmetricMatch' in obj && isA('Function', obj.asymmetricMatch)
}

export function hasAsymmetric(obj: any, seen = new Set()): boolean {
Expand Down

0 comments on commit 757199a

Please sign in to comment.