forked from NagRock/ts-mockito
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Example
https://stackblitz.com/edit/vitest-dev-vitest-qg1hxb?file=test%2Fbasic.test.ts
If a function call is made on a Mock which takes a null parameter, which is then verified and fails, it produces a non-useful error message.
TypeError: Cannot read properties of null (reading 'hasOwnProperty')
❯ MethodCallToStringConverter.objectIsStringable node_modules/@typestrong/ts-mockito/lib/utils/MethodCallToStringConverter.js:21:47
❯ eval node_modules/@typestrong/ts-mockito/lib/utils/MethodCallToStringConverter.js:16:68
❯ eval node_modules/@typestrong/ts-mockito/lib/utils/MethodCallToStringConverter.js:16:34
❯ MethodCallToStringConverter.convertActualCalls node_modules/@typestrong/ts-mockito/lib/utils/MethodCallToStringConverter.js:14:22
❯ MethodStubVerificator.actualCalls node_modules/@typestrong/ts-mockito/lib/MethodStubVerificator.js:91:76
❯ MethodStubVerificator.times node_modules/@typestrong/ts-mockito/lib/MethodStubVerificator.js:30:62
❯ MethodStubVerificator.once node_modules/@typestrong/ts-mockito/lib/MethodStubVerificator.js:17:14
It looks like objectIsStringable()
in src/utils/MethodCallToStringConverter.ts
can't handle null values (including I assume undefined
), since it tries to do arg.hasOwnProperty("toString");
if the arg is not an Object, which will immediately fail.
Metadata
Metadata
Assignees
Labels
No labels