Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including mockttp with all npm packages installed. Try it out:

const expect = require("chai").expect; const superagent = require("superagent"); const mockServer = require("mockttp").getLocal(); mockServer.start(8080) .then(() => { // Mock your endpoints return mockServer.get("/mocked-path").thenReply(200, "A mocked response"); }).then(() => { // Make a request return superagent.get("http://localhost:8080/mocked-path"); }).then((response) => { // Assert on the results expect(response.text).to.equal("A mocked response"); console.log("Test passed!"); });

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mockttp v2.4.0

Mock HTTP server for testing HTTP clients and stubbing webservices

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free