How to use the mock-require.stopAll function in mock-require

To help you get started, we’ve selected a few mock-require 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 xuexb / github-bot / test / utils.js View on Github external
/**
 * @file utils.js test case
 * @author xuexb 
 */
require('mock-require').stopAll()
const utils = require('../src/utils')
const expect = require('chai').expect

describe('utils.js', () => {
  describe('.toArray', () => {
    it('should return self if empty', () => {
      expect(utils.toArray()).to.be.undefined
      expect(utils.toArray('')).to.equal('')
      expect(utils.toArray(null)).to.be.null
    })
    it('should return array if not the empty string', () => {
      expect(utils.toArray(['string'])).to.be.a('array').and.to.deep.equal(['string'])
      expect(utils.toArray('string')).to.be.a('array').and.to.deep.equal(['string'])
    })
  })
github standard-things / esm / test / fixture / scenario / jest-mock-require / index.js View on Github external
"use strict"

require("mock-require").stopAll()
require = require("../../../../index.js")(module)
module.exports = require("./main.mjs")

mock-require

Simple, intuitive mocking of Node.js modules.

MIT
Latest version published 6 years ago

Package Health Score

56 / 100
Full package analysis