dvabuzyarov / moq.ts

Moq for Typescript
Apache License 2.0
120 stars 9 forks source link

fix(constant.formatter): Makes constant formatter serialize objects in a useful way #1034

Closed runia1 closed 9 months ago

runia1 commented 9 months ago

Description

Moq.ts is a great library but sometimes can be hard to track down test failures due to the way data objects are serialized. For example, you may get an error message that looks like:

     Error: upsert(0, [object Object]) should be called once, but was called 0 time(s)
-------------------------------------
Tracked calls:
Getter of 'upsertMany'
upsert(0, [object Object])
-------------------------------------

With this fix, the error messages will be more useful such as:

     Error: upsert(0, {'hello': 'world'}) should be called once, but was called 0 time(s)
-------------------------------------
Tracked calls:
Getter of 'upsertMany'
upsert(0, {'hello': 'world!'})
-------------------------------------
dvabuzyarov commented 8 months ago

Hello, I reimplemented it in an extendable way, it is not documented yet, but the default implementation should meet your needs. You can find a new version of the library on the next tag.

dvabuzyarov commented 8 months ago

:tada: This PR is included in version 10.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: