You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

e2e-proxy

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

e2e-proxy

1.7.0
latest
npmnpm
Version published
Weekly downloads
295
-13.74%
Maintainers
1
Weekly downloads
 
Created
Source

E2E Proxy

In order to maximise coverage via end to end automated tests on web and mobile, this small library acts as a proxy where you can queue mocks for errors and responses.

Install

npm i e2e-proxy --save

Running

e2e-proxy

Example usage

Make a request to https://jsonplaceholder.typicode.com/todos/1

curl --location --request GET 'http://localhost:5000/?url=https://jsonplaceholder.typicode.com/todos/1'

Return an error for the next request to https://jsonplaceholder.typicode.com/todos/1

curl --location --request POST 'http://localhost:5000/?url=todos/1&baseUrl=https://jsonplaceholder.typicode.com/&error=1' \
--header 'Content-Type: text/plain' \
--data-raw '{"error":"Mocked error"}'
# This next request will return the specified error
curl --location --request GET 'http://localhost:5000/?url=https://jsonplaceholder.typicode.com/todos/1&baseUrl=https://jsonplaceholder.typicode.com/'

Return a specific response for the next request to https://jsonplaceholder.typicode.com/todos/1

curl --location --request POST 'http://localhost:5000/?url=todos/1&baseUrl=https://jsonplaceholder.typicode.com/&mock=1' \
--header 'Content-Type: text/plain' \
--data-raw '{"userId": 2,"id": 2,"title": "test data","completed": false}'
# This next request will return the specified error
curl --location --request GET 'http://localhost:5000/?url=https://jsonplaceholder.typicode.com/todos/1&baseUrl=https://jsonplaceholder.typicode.com/'

Dealing with concurrent requests

If you need to mock requests for the same URL concurrently you can specify a namespace for mocks, this will ensure that race conditions do not consume any mocks or errors.

curl --location --request POST 'http://localhost:5000/?namespace=test1&url=todos/1&baseUrl=https://jsonplaceholder.typicode.com/&mock=1' \
--header 'Content-Type: text/plain' \
--data-raw '{"userId": 2,"id": 2,"title": "test data","completed": false}'
# This next request will return the specified error
curl --location --request GET 'http://localhost:5000/?namespace=test1&url=https://jsonplaceholder.typicode.com/todos/1&baseUrl=https://jsonplaceholder.typicode.com/'

FAQs

Package last updated on 28 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.