Skip to content

Instantly share code, notes, and snippets.

@madrus
Last active August 20, 2022 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madrus/9bfd67b88aae0459dcf16b5acf911160 to your computer and use it in GitHub Desktop.
Save madrus/9bfd67b88aae0459dcf16b5acf911160 to your computer and use it in GitHub Desktop.
Mock HTTP Server

Taken from cube.js

/* globals jest */
/* eslint-disable no-underscore-dangle */

const http = jest.requireActual('http');

http.__mockServer = {
  listen: jest.fn((opts, cb) => cb && cb(null)),
  close: jest.fn((cb) => cb && cb(null)),
  delete: jest.fn()
};

http.createServer = jest.fn(() => http.__mockServer);

module.exports = http;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment