modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.19k stars 278 forks source link

[docs] Guide on mocks, spies and stubs in tests #410

Open LarsDenBakker opened 4 years ago

LarsDenBakker commented 4 years ago

We should have a section in our guide how to use mocks, spies and stubs using Sinon in tests. And mocking es modules in tests using import maps.

Manish3323 commented 3 years ago

hi, is there a sample repo or something which i can refer to. I am finding it hard to mock classes and use the same mocks in import maps.


Link to some examples : https://github.com/modernweb-dev/example-projects

hegsie commented 3 years ago

It'd also be good to see how to stub a @customelement constructor using sinon included in this

spacejamjim commented 3 years ago

I am having trouble simply stubbing something like React Router's useLocation hook -- it makes me want to switch from test-runner to jest