How To articles
This is a collection of how to articles for common scenarios using Sinon.JS.
- How to stub out CommonJS modules
- How to test async functions with fake timers
- How to stub a dependency of a module
- Case study: real world dependency stubbing
Related libraries
- proxyquire — Proxies nodejs require in order to allow overriding dependencies during testing
- inject-loader - Webpack loader that allows overriding dependencies during testing
- sisyphos — utility to stub modules imported with the System.js module loader
- bogus — utility for mocking dependencies when testing RequireJS based projects
- fetch-mock — Mock http requests made using fetch
- fake-fetch — fake window.fetch for tests
- Mock Socket — mocking library for websockets and socket.io
- wrapple — generic wrapper for browser natives (or other globals) to allow stubbing in unit tests
- test double — minimal test double library for TDD with JavaScript
Articles elsewhere on the web
- How to Test NodeJS Apps using Mocha, Chai and SinonJS
- How to test an Ajax request using Sinon's fake XMLHttpRequest
- How to stub or mock complex objects, such as DOM objects
- Using Sinon.js with Promises
- Best practices for spies, stubs and mocks
- Using Sinon.js to help test Mongoose models
- Stubbing HTTP Requests With Sinon
- Stubbing Node Authentication Middleware with Sinon
- Testing ImmutableJS with Sinon custom matchers
- SinonJS Fundamentals