Chai plugin for fetch-mock library version 3.0.0. Provides Chai assertions for fetch-mock, a mocking library for fetch() and isomorphic-fetch. Active maintenance, weekly release cadence. Differentiator: adds fluent BDD-style assertions like `.called`, `.with.args()`, `.with.url()`, `.with.options()` for fetch-mock routes, requiring careful ordering with other Chai plugins. Supports Node.js 7+ and Chai 3.x/4.x, fetch-mock 5.1.x/6.x. Note: fetch-mock 6.0 requires Node >=7.
npm install chai-fetch-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a fetch mock, applies the chai-fetch-mock plugin, and uses various route assertions.
Always start the assertion chain with .route(urlOrName), e.g., expect(fetchMock).route('/path').to.have.been.calledOrder plugin registration: sin·on-chai first, then chai-fetch-mock
Update to fetch-mock >=6.0.0 and Node >=7
Pass array of arguments: [url, options]
Place assertions inside the .then() callback after the fetch promise resolves
const chai = require('chai') or import chai from 'chai'Add .route('/path') before .to.have.been.calledMake sure fetchMock is imported and passed: expect(fetchMock).route(...)