# Mock Service Worker

[BASE product page](<https://base.akulich.dev/en/library/mock-service-worker/>) · [Resource](<https://github.com/mswjs/msw>)

ID: mock\-service\-worker · Language: en
Schema version: 1 · Data version: cbbe7123b47a5ae80983

This is editorial data. An unknown field neither confirms nor rules out a capability.
dataVersion is a dataset fingerprint, not evidence of a recent fact check.

Intercepts network requests in browsers and Node\.js, allowing application checks with realistic API mocks without a separate server\.

## Type

Test automation

## Entry type

tool

## Separate catalog

No

## [Access conditions](<https://base.akulich.dev/en/library/mock-service-worker/#resource-access>)

free

## [What you can use for free](<https://base.akulich.dev/en/library/mock-service-worker/#resource-access>)

Code and local use under MIT\.

## [Paid features and costs](<https://base.akulich.dev/en/library/mock-service-worker/#resource-access>)

Compute, your own hosting, and external services are paid for separately if selected\.

## [Access and limitations](<https://base.akulich.dev/en/library/mock-service-worker/#resource-access>)

Code and local use under MIT\. Compute, your own hosting, and external services are paid for separately if selected\.

## [Use cases](<https://base.akulich.dev/en/library/mock-service-worker/#resource-tasks>)

- Check an interface with reproducible API responses
- Connect interception to a browser or Node\.js test environment

## Category IDs

- quality

## Subcategory IDs

- quality\.testing

## Tags

- Mock Service Worker
- test
- Development

## Also known as

- mswjs/msw
- mock\-service\-worker
- msw\-api\-mocking

## [Selection purpose](<https://base.akulich.dev/en/library/mock-service-worker/#resource-selection>)

Check an interface with reproducible API responses

## [Choose this when](<https://base.akulich.dev/en/library/mock-service-worker/#resource-selection>)

- Check an interface with reproducible API responses
- Connect interception to a browser or Node\.js test environment

## [Requirements](<https://base.akulich.dev/en/library/mock-service-worker/#resource-selection>)

- Choose browser/node setup and configure request handlers for the APIs in use\.

## [Limitations](<https://base.akulich.dev/en/library/mock-service-worker/#resource-selection>)

- Costs and limits of free use: Compute, your own hosting, and external services are paid for separately if selected\.
- Terms of use: MIT: code; dependencies have separate licenses\.
- Browser and Node interception use different mechanisms; the browser route requires a Service Worker, while Node does not\.

## [Questions before use](<https://base.akulich.dev/en/library/mock-service-worker/#resource-faq>)

### What can you use for free in Mock Service Worker?

Code and local use under MIT\.

### What additional costs might arise with Mock Service Worker?

Compute, your own hosting, and external services are paid for separately if selected\.

### What terms of use matter for Mock Service Worker?

MIT: code; dependencies have separate licenses\.

### How do you get started with Mock Service Worker?

Define request handlers for the required endpoints and response states\. Connect interception to a browser or Node\.js test environment\. Run the check locally and save the report in CI\.

### Does MSW use the same mechanism in browsers and Node\.js?

In a browser, MSW uses a Service Worker to intercept requests at the network level; handlers execute on the client rather than inside the worker\. Node\.js has no Service Worker and uses low\-level interception\. Shared request handlers can be reused for development, unit/integration tests, and E2E, adding browser setupWorker or node setupServer according to the environment\.

## Sources for the selection guide

- [https://github\.com/mswjs/msw](<https://github.com/mswjs/msw>)
- [https://raw\.githubusercontent\.com/mswjs/msw/HEAD/README\.md](<https://raw.githubusercontent.com/mswjs/msw/HEAD/README.md>)
- [https://raw\.githubusercontent\.com/mswjs/msw/HEAD/LICENSE\.md](<https://raw.githubusercontent.com/mswjs/msw/HEAD/LICENSE.md>)
- [https://www\.open\-source\-tools\.com/](<https://www.open-source-tools.com/>)

## [Possible workflow](<https://base.akulich.dev/en/library/mock-service-worker/#resource-scenario>)

Check an interface with reproducible API responses\.

A possible workflow; this is not a report of hands-on testing.

## Before you start

- One important workflow and its expected result\.
- A test environment with controlled data\.

## Steps

1. Define request handlers for the required endpoints and response states\.
2. Connect interception to a browser or Node\.js test environment\.
3. Run the check locally and save the report in CI\.

## Check your result

- The check detects a deliberately broken workflow\.
- The result can be reproduced without depending on a personal session\.

## [License](<https://base.akulich.dev/en/library/mock-service-worker/#resource-license>)

MIT: code; dependencies have separate licenses\.

## License explanations for the specified scope

### MIT — permissive license

You can use, modify, distribute, and sell the code, including in a closed\-source commercial product\. When sharing copies or substantial portions of the code, retain the license text and copyright notice\. You do not need to open\-source your entire project; the author provides no warranties\.

[License terms](<https://opensource.org/license/mit>)

## [Sources](<https://base.akulich.dev/en/library/mock-service-worker/#resource-sources>)

- [Official source](<https://github.com/mswjs/msw>)
- [Official source](<https://raw.githubusercontent.com/mswjs/msw/HEAD/README.md>)
- [License](<https://raw.githubusercontent.com/mswjs/msw/HEAD/LICENSE.md>)
- [Catalog / discovery source](<https://www.open-source-tools.com/>)

## Editorial review date

2026\-10\-06

## Editorial review scope

Purpose, the current repository license, and the boundaries between code, services, and models were reviewed\. The product was not run or security\-audited\.

Dates refer to the stated editorial review, not hands-on testing, a product update, or a recent review of all sources.
