stop()
Stops the mocking for the current client.
Usage
1// src/mocks.js2import { setupWorker } from 'msw'34const worker = setupWorker(...mocks)56// Start the worker by default7worker.start()89// Write the stop method on the window10// 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.