Skip to content
PluginStats

msw-request-assertions weekly downloads statistics

By marklai1998 · npm · Testing

Request assertions for MSW

View on npm Fresh · Dec 6, 2026

msw-request-assertions has 7,775 recorded weekly downloads on npm, an increase of 863% over the past 30 days, ranking #1367 of 3,247 tracked listings.

Weekly downloads
7,775
Official API · Dec 5, 2026
7-day growth
-8.2%
-697 weekly downloads
30-day growth
+863%
+7K weekly downloads
90-day growth
+5835%
+7.6K weekly downloads
Rank
#1367
▼ 62 in 7 days

About msw-request-assertions

MSW Request Assertions

<div align="center">

A powerful testing library that provides custom assertion matchers for Mock Service Worker (MSW). Test your API interactions with confidence by asserting on request properties like headers, body, query parameters, and more.

NPM GitHub CI Conventional Commits npm type definitions

Features | Installation | Migration | API | Contributing

</div>

[!IMPORTANT]
Before using this library, please read MSW's official guidance on avoiding request assertions. The MSW team recommends testing how your application reacts to requests rather than asserting on request details. This library should primarily be used for edge cases, like request details have no observable application behavior.

✨ Features

  • ✅ Assert on any aspect of HTTP and GraphQL requests
  • ✅ Works with Vitest and Jest

📦 Installation

npm install --save-dev msw-request-assertions msw
# or
yarn add --dev msw-request-assertions msw
# or
pnpm add --save-dev msw-request-assertions msw

🚀 Quick Start

Setup for Vitest

msw-request-assertions/vitest ships Vitest 5 matcher types (Matchers<R, T>).

// vitest.setup.ts
import 'msw-request-assertions/vitest';
// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    setupFiles: ['./vitest.setup.ts'],
  },
});
// tsconfig.json
{
  "compilerOptions": {
    // ...rest of your options
    "types": ["vitest/globals", "msw-request-assertions/vitest"]
  }
}

Requires Vitest 5.

Setup for Jest

[!NOTE]
Jest support is not a first-class citizen. This package is ESM only, so Jest must run in ESM mode. While we provide Jest compatibility, our main development and testing efforts are focused on Vitest. Feel free to raise an issue if you encounter Jest-specific problems.

// jest.setup.ts
import 'msw-request-assertions/jest';
// jest.config.js
module.exports = {
  setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
};
// tsconfig.json
{
  "compilerOptions": {
    // ...rest of your options
    "types": ["vitest/globals", "msw-request-assertions/jest"]
  }
}

Basic Example
import { http, HttpResponse } from 'msw';
import { setupServer } from 'msw/node';

// Create MSW handlers
const userHandler = http.post('/api/users', () => {
  return HttpResponse.json({ id: 1, name: 'John Doe' });
});

const server = setupServer(userHandler);

beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

test('should create user with correct data', async () => {
  const userData = { name: 'John Doe', email: 'john@example.com' };

  await fetch('/api/users', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(userData),
  });

  // Assert the request was made
  expect(userHandler).toHaveBeenRequested();

  // Assert the request body
  expect(userHandler).toHaveBeenRequestedWithJsonBody(userData);

  // Assert multiple properties at once
  expect(userHandler).toHaveBeenRequestedWith({
    jsonBody: userData,
    headers: { 'content-type': 'application/json' },
  });
});

🔄 Migration

MSW 3 (breaking)

Peer dependency is msw@^3. Node.js 22 or newer is required.

GraphQL handlers are created from graphql.link() (msw/graphql). This library patches query and mutation on the link, so import the setup file before calling graphql.link().

import { HttpResponse } from 'msw';
import { graphql } from 'msw/graphql';
import 'msw-request-assertions/vitest';

const api = graphql.link('http://localhost/graphql');

const getUser = api.query('GetUser', () => {
  return HttpResponse.json({ data: { user: { id: '1' } } });
});

Install graphql when you assert on GraphQL handlers. MSW 3 treats it as an optional peer.

server.listen({ onUnhandledRequest }) is now onUnhandledFrame in MSW itself.

toHaveBeenRequestedWithHash, toHaveBeenNthRequestedWithHash, and the hash field on toHaveBeenRequestedWith are removed. MSW 3 does not expose the URL fragment on the intercepted request.

ESM only (breaking)

The package ships ES modules only. The CommonJS build (dist/cjs, require()) is removed. Use import, or run Jest in ESM mode.

Vitest 5 only (breaking)

Vitest 3 and 4 are no longer supported, and the msw-request-assertions/vitest/v4 entry point is removed. msw-request-assertions/vitest types match Vitest 5's Matchers<R, T>. Upgrade to Vitest 5 and keep the existing import:

import 'msw-request-assertions/vitest';

💻 API…

Description from the npm listing.

  • msw
  • vitest
  • vitest-plugin
  • api
  • mock
  • mocking
  • testing

README badge

Show your rank in a README or on your website. The badge updates automatically.

Charts

Images: 30d · 1y · all time · 1600×900 dark

Adoption over time

msw-request-assertions weekly downloads on npm, last 90 days: 7,775 weekly downloads as of Dec 5, 2026, +5835% over 90 days.msw-request-assertionsWeekly downloads on npm · Last 90 days7,775downloads / week+5835% over 90 days02K4K6K8K10KSep 6Sep 21Oct 6Oct 21Nov 5Nov 20Dec 5downloads / weekobservedarchived (Internet Archive)no observationsSep 7, 2026 – Dec 5, 2026 · 90 observations · Updated Dec …pluginstats.com
msw-request-assertions weekly downloads on npm, last 90 days: 7,775 weekly downloads as of Dec 5, 2026, +5835% over 90 days.

7/30/90-day growth

msw-request-assertions weekly downloads growth on npm: -8.2% over 7 days, +863% over 30 days, +5835% over 90 days.msw-request-assertionsWeekly downloads growth on npm7,775downloads / week now7-day growth-697 weekly downloads-8.2%30-day growth+6,968 weekly downloads+863%90-day growth+7,644 weekly downloads+5835%Growth vs. nearest observation to each baseline date · Updated Dec 5, 2026pluginstats.com
msw-request-assertions weekly downloads growth on npm: -8.2% over 7 days, +863% over 30 days, +5835% over 90 days.

Ranking history

msw-request-assertions npm ranking history: currently #1367 (by weekly downloads).msw-request-assertionsnpm ranking · by weekly downloads · Last 90 days#1367current rank#400#600#800#1000#1200#1400#1600#1800#2000Sep 7Sep 22Oct 7Oct 22Nov 6Nov 21Dec 6rankOct 17, 2026 – Dec 6, 2026 · 45 observations · Updated Dec 5, 2026pluginstats.com
msw-request-assertions npm ranking history: currently #1367 (by weekly downloads).

Listing placement

All npm3,247 listings · 163 pages · 1,084 shown · page 69, #7 (overall #1,367)
All npm: every listing in weekly downloads order

Listing placement

Testing26 listings · 2 pages · page 1, #4 (overall #4)
Testing: every listing in weekly downloads order

Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.

Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.

Recent observations

Full history (592)
Recent weekly downloads observations for msw-request-assertions
Date (UTC)Weekly downloadsChange vs. previous
7,775-646
8,421-538
8,959+50
8,909+637
8,272-215
8,487-195
8,682+210
8,472+619
7,853+1.3K
6,586-898
7,484-1.1K
8,579+82
8,497-76
8,573—

Data source

Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.

Listing: https://www.npmjs.com/package/msw-request-assertions. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.