Packages

msw

3.0.7 · 18 Nov 2026MIT36M / weekRepositoryHomepagenpmAtom feed

Your version

0.23.0

29 Nov 2020Where it was published

0.49.3 is the newest release of 0.23.x.

In short

1 new

Release note

Features

  • Supports asynchronous response transformers (#465, #467).

import { ResponseTransformer, compose } from 'msw'
import base64Image from 'url-loader!../../fixtures/image.jpg'

async function jpeg(base64: string): Promise<ResponseTransformer> {
  const buffer = await fetch(base64).then((res) => res.arrayBuffer())

  return compose(
    context.set('Content-Length', buffer.byteLength.toString()),
    context.set('Content-Type', 'image/jpeg'),
    context.body(buffer),
  )
}

const worker = setupWorker(
  rest.get('/image', async (req, res, ctx) => {
    return res(await jpeg(base64Image))
  }),
})
  • Publicly exposes the compose function (#467).

import { compose } from 'msw'

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.