How to use the find-up.mock function in find-up

To help you get started, we’ve selected a few find-up 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 sezna / nps / src / bin-utils / __tests__ / parser.js View on Github external
test('init without an existing package.json will fail', () => {
  mockFindUp.mock.syncFail = true
  mockFindUp.mock.syncReturn = undefined

  const result = parse('init')
  expect(result).toBe(undefined)
  expect(mockReadLine.keyInYN).toHaveBeenCalledTimes(0)
  expect(mockGetLogger.mock.error).toHaveBeenCalledWith(
    expect.stringMatching(/Unable/),
  )

  delete mockFindUp.mock.syncFail
  delete mockReadLine.mock.keyInYNReturn
  delete mockFindUp.mock.syncReturn
})
github sezna / nps / src / bin-utils / __tests__ / parser.js View on Github external
test('init without an existing package.json will fail', () => {
  mockFindUp.mock.syncFail = true
  mockFindUp.mock.syncReturn = undefined

  const result = parse('init')
  expect(result).toBe(undefined)
  expect(mockReadLine.keyInYN).toHaveBeenCalledTimes(0)
  expect(mockGetLogger.mock.error).toHaveBeenCalledWith(
    expect.stringMatching(/Unable/),
  )

  delete mockFindUp.mock.syncFail
  delete mockReadLine.mock.keyInYNReturn
  delete mockFindUp.mock.syncReturn
})
github sezna / nps / src / bin-utils / __tests__ / parser.js View on Github external
test('with CLI config', () => {
  mockFindUp.mock.cliReturn = '/path/to/.npsrc'
  mockBinUtils.mock.cliConfig = {
    require: 'ts-node/register',
    config: 'package-scripts.ts',
  }
  const {argv, psConfig} = parse('"build --fast"')
  expect(mockBinUtils.loadConfig).toHaveBeenCalledTimes(1)
  expect(mockBinUtils.loadCLIConfig).toHaveBeenCalledTimes(1)
  expect(psConfig.isMock).toBe(true)
  expect(argv).toEqual(
    expect.objectContaining({
      _: [`\"build --fast\"`],
      require: 'ts-node/register',
      config: 'package-scripts.ts',
    }),
  )
github sezna / nps / src / bin-utils / __tests__ / parser.js View on Github external
initialize: jest.fn(() => {
      if (mockFindUp.mock.syncFail) {
        return undefined
      }
      return {
        packageScriptsPath: '/path/to/package-scripts.js',
        packageJsonPath: '/path/to/package.json',
      }
    }),
    help: jest.fn(),
github sezna / nps / src / bin-utils / __tests__ / parser.js View on Github external
() => {
    mockReadLine.mock.keyInYNReturn = true
    mockFindUp.mock.syncReturn = '/some/path/to/things'

    const result = parse('init foo.js')
    expect(result).toBe(undefined)
    expect(mockGetLogger.mock.info).toHaveBeenCalledWith(
      expect.stringMatching(/saved/),
    )

    delete mockReadLine.mock.keyInYNReturn
    delete mockFindUp.mock.syncReturn
  },
)

find-up

Find a file or directory by walking up parent directories

MIT
Latest version published 8 months ago

Package Health Score

80 / 100
Full package analysis