Hi! 👋
I had a problem using createMock from @golevelup/ts-jest because it uses proxies to fake properties, and the test below against _isAllArgsFunctionMatcher gives a false positive (returns a jest.fn() instance).
Here is the diff that solved my problem:
diff --git a/node_modules/jest-when/src/when.js b/node_modules/jest-when/src/when.js
index 760b9bb..b7590bc 100644
--- a/node_modules/jest-when/src/when.js
+++ b/node_modules/jest-when/src/when.js
@@ -93,7 +93,7 @@ class WhenMock {
let isMatch = false
- if (matchers && matchers[0] && matchers[0]._isAllArgsFunctionMatcher) {
+ if (matchers && matchers[0] && (typeof matchers[0] === 'function' || typeof matchers[0] === 'object') && '_isAllArgsFunctionMatcher' in matchers[0] && matchers[0]._isAllArgsFunctionMatcher) {
if (matchers.length > 1) throw new Error('When using when.allArgs, it must be the one and only matcher provided to calledWith. You have incorrectly provided other matchers along with when.allArgs.')
isMatch = checkArgumentMatchers(expectCall, [args])(true, matchers[0], 0)
} else {
Hi! 👋
I had a problem using
createMockfrom@golevelup/ts-jestbecause it uses proxies to fake properties, and the test below against_isAllArgsFunctionMatchergives a false positive (returns a jest.fn() instance).Here is the diff that solved my problem: