Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
})
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)
})