How to use the execa.mockResolvedValueOnce function in execa

To help you get started, we’ve selected a few execa 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 / resolveTaskFn.spec.js View on Github external
it('should set hasErrors on context to true on error', async () => {
    execa.mockResolvedValueOnce({
      stdout: 'Mock error',
      stderr: '',
      code: 0,
      failed: true,
      cmd: 'mock cmd'
    })
    const context = {}
    const taskFn = resolveTaskFn({ ...defaultOpts, linter: 'mock-fail-linter' })
    expect.assertions(1)
    try {
      await taskFn(context)
    } catch (err) {
      expect(context.hasErrors).toEqual(true)
    }
  })
})