Mocking methods in Tape Node js

2k Views Asked by At

What is the way to mock methods in unit tests using tape in Node js? I did not find anything in readme. I am pretty new to Node js, so this question seems pretty simple to some people.

Please provide some suggestions.

1

There are 1 best solutions below

0
Lin Du On

tape is a lightweight test library. It doesn't support mock,spy,stub or fake features. It tends to do the underlying testing which means your code doesn't depend on any external resource, E.g. database, web service, http request and so on

If your code very depends on these external resource, you can use

  • sinon has mock/spy/stub/fake feature.
  • jest has mock/spy feature

Both of them are ok.