LOGOMock Service Worker

stop()

Stops the mocking for the current client.

Usage

1// src/mocks.js
2import { setupWorker } from 'msw'
3
4const worker = setupWorker(...mocks)
5
6// Start the worker by default
7worker.start()
8
9// Write the stop method on the window
10// to access during runtime.
11window.__mswStop = worker.stop

Calling window.__mswStop() in the browser would disable the mocking for the current page.

The mocking's disabled state does not persist between page reloads. When the page is refreshed, its JavaScript code will run again, calling worker.start(), thus, enabling the mocking.