Skip to content

Instantly share code, notes, and snippets.

@madrus
Last active August 20, 2022 13:15
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/d36b38ce64e0007a88af6d42f0cd32f8 to your computer and use it in GitHub Desktop.
Save madrus/d36b38ce64e0007a88af6d42f0cd32f8 to your computer and use it in GitHub Desktop.
Mock HTTPS Server

Taken from cube.js

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

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

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

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

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