How to use mock-http-server - 1 common examples

To help you get started, we’ve selected a few mock-http-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-data-plan / crawler / test / index.spec.ts View on Github external
import MockServer from 'mock-http-server'
import Crawler from '../src'

const server = new MockServer({ host: 'localhost', port: 9000 }, null)

const createPage = (id: string) => {
  server.on({
    method: 'GET',
    path: `/${id}`,
    reply: {
      status: 200,
      headers: { 'content-type': 'text/html' },
      body: `<div id="node">${id}</div>`
    }
  })
  return `http://localhost:9000/${id}`
}

beforeEach(done =&gt; {
  server.start(done)

mock-http-server

Controllable HTTP Server Mock for your functional tests

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular mock-http-server functions

Similar packages