How to use the npm-which.mockFn function in npm-which

To help you get started, we’ve selected a few npm-which 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 okonet / lint-staged / test / findBin.spec.js View on Github external
it('should throw a helpful error if the cmd is present in pkg scripts', () => {
    const originalConsole = global.console
    global.console = makeConsoleMock()
    npmWhichMock.mockFn.mockImplementationOnce(() => {
      throw new Error()
    })

    expect(() => {
      findBin('lint')
    }).toThrow('Could not resolve binary for `lint`')
    expect(console.printHistory()).toMatchSnapshot()

    global.console = originalConsole
  })
github okonet / lint-staged / test / findBin.spec.js View on Github external
it('should resolve path to bin from cache for subsequent invocations', () => {
    npmWhichMock.mockFn.mockClear()
    findBin('my-cmd')
    expect(npmWhichMock.mockFn).toHaveBeenCalledTimes(1)
    findBin('my-cmd --arg')
    expect(npmWhichMock.mockFn).toHaveBeenCalledTimes(1)
  })

npm-which

Locate a program or locally installed node module's executable

MIT
Latest version published 8 years ago

Package Health Score

53 / 100
Full package analysis

Popular npm-which functions