Wildhoney / Mocktail

:tropical_drink: Mock all of your ES6 module components with Mocktail using dependency injection.
http://mocktail.herokuapp.com/
MIT License
103 stars 6 forks source link

Mocking builtin or libraries? #6

Open sarbbottam opened 8 years ago

sarbbottam commented 8 years ago
// request-foo.js
import {mock} from 'mocktail';
import foo from 'foo'; // foo is a third-party dependency that makes and io operation 

class Request {
  ...
}
export default mock(Request);

How am I going to mock foo while testing request-foo.js? Any pointer would be helpful. Thanks!!

nhz-io commented 8 years ago

One way, would go like this:

...
import _foo from 'foo'
const foo = mock(_foo, 'foo')
...