close
Skip to content

vitalets/request-mocking-protocol

Repository files navigation

Request Mocking Protocol logo

Request Mocking Protocol

lint test npm version license

Request Mocking Protocol (RMP) is a specification for HTTP requests mocking in end-to-end tests. It uses declarative JSON schemas to define mocked request and response. These schemas can be serialized and sent over the network, enabling both client-side and server-side mocking.

Server-Side Mocking

RMP lets you mock API calls made by your application server. Here's how it works:

How server-side mocking works

  1. A test defines mock schemas and sends them to the app server in a custom HTTP header: x-mock-request.
  2. The server-side interceptor reads that header and applies the mocks to the outgoing API calls.
  3. The page is rendered with mocked data, and the test can assert the expected UI state.

This is ideal for server-side rendered pages, where data is fetched on the server before the page reaches the browser. Learn how to set it up in Server-Side Mocking →

Client-Side Mocking

RMP also lets you mock requests made directly in the browser, using the same declarative schemas. It works with any framework, no special integration needed.

This is ideal for single-page apps and any data fetched on the client. Learn how to set it up in Client-Side Mocking →

📖 Documentation

Full documentation is available at vitalets.github.io/request-mocking-protocol.

License

MIT

About

A protocol for declarative mocking of HTTP requests.

Resources

License

Stars

34 stars

Watchers

2 watching

Forks

Sponsor this project

 

Packages

 
 
 

Contributors