Better HN
topnewbestaskshowjobs
Log inSign up

sayan51

1 karma · joined Jun 26, 2021 (5y ago) · 4 submissions

Submissions

comment 5y ago · link · parent

In my projects things are arranged in terms of class, and dependencies are injected to constructor using dependency injection. Then the requirements of mocking the dependencies during unit tests bolis down to mocking parts or whole of the implementation as well as recording those method cqlls. The spy implementation is based on that philosophy and is therefore simple, straightforward and tiny.

comment 5y ago · link · parent

Good question! I am not a user of Jest. So can't really comment on that. Taking a look at the docs from jest, it seems to me that my spy API is far more straightforward. Also it can be used by itself. Theoretically it can also be used without unit testing. It happens to be the case that spy is used generally in tests. Another point to note is that the implementation is not tied to any test framework.

comment 5y ago · link · parent

It can be used with test framework. Also it provides great type definition for the object being mocked, its method and arguments' types.

4.

Netatwork/spy: Tiny proxy-based impl to mock and spy dependencies in unit tests(github.com ↗)

1 points · by sayan51 · 5y ago · 4 comments