Packages

msw

3.0.7 · 18 Nov 2026MIT36M / weekRepositoryHomepagenpmAtom feed

Your version

0.16.0

16 May 2020Where it was published

0.49.3 is the newest release of 0.16.x.

In short

1 breaking1 fixed1 internal

  • Breaking

    The req.url reference in request handlers is now a URL instance (#158):

Release note

This release introduces bug fixes to the Service Worker file. Please follow the update instructions in your browser's console. Thanks.

Breaking changes

  • Breaking

    The req.url reference in request handlers is now a URL instance (#158):

rest.get('/user', (req) => {
-  req.url // "/user"
+  req.url.href // "/user"
})

Features

// test/LoginForm.test.js
import { rest } from 'msw'
import { setupServer } from 'msw/node'

describe('LoginForm', () => {
  const server = setupServer(
    rest.post('/login', (req, res, ctx) => {
      return res(ctx.json({ success: true }))
    })
  )

  beforeAll(() => {
    server.listen()
  })

  afterAll(() => {
    server.close()
  })

  it('allows a user to log in', () => {
    // your assertions here...
  })
})

Bug fixes

  • Fixes an issue that resulted into the last value of a multi-value header being available in req.headers

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.