How to use the execa.mock 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 nklayman / vue-cli-plugin-electron-builder / __tests__ / commands.spec.js View on Github external
// Set callback to be called later
          watchCb = cb
        }
      }
    })
    await runCommand('electron:serve', {
      pluginOptions: {
        electronBuilder: {
          mainProcessFile: 'customBackground',
          mainProcessArgs: ['--a-flag', 'a-value']
        }
      }
    })

    expect(execa).toHaveBeenCalledTimes(1)
    expect(execa.mock.calls[0][1]).toEqual([
      'dist_electron',
      '--a-flag',
      'a-value'
    ])

    // Mock change of background file
    watchCb()
    expect(mockExeca.removeListener.mock.calls[0][0]).toBe('exit')

    expect(execa).toHaveBeenCalledTimes(2)
    expect(execa.mock.calls[0][1]).toEqual([
      'dist_electron',
      '--a-flag',
      'a-value'
    ])
  })
github nklayman / vue-cli-plugin-electron-builder / __tests__ / commands.spec.js View on Github external
test('Electron is launched with arguments', async () => {
    await runCommand('electron:serve', {}, {}, ['--expected'])
    const args = execa.mock.calls[0][1]
    expect(args).toContain('--expected')
  })
})
github kazupon / vue-cli-plugin-p11n / tests / unit / services / docs.spec.js View on Github external
test('docs', () => {
  const service = require('../../../lib/docs/service')
  const mockExeca = require('execa')

  service('/bin/vuepress', { mode: 'build' })

  const calls = mockExeca.mock.calls
  expect(calls[0][0]).toMatch('/bin/vuepress')
  expect(calls[0][1]).toEqual(['build', 'docs'])
  expect(calls[0][2]).toEqual({ stdio: 'inherit' })
})