How to use the cross-spawn.mockReturnValue function in cross-spawn

To help you get started, we’ve selected a few cross-spawn 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 Yoctol / bottender / packages / bottender / src / cli / providers / sh / __tests__ / init.spec.js View on Github external
it('should catch error when install failed', async () => {
      spawn.mockReturnValue({
        on: jest.fn((action, callback) => callback(1)),
      });
      fs.readdirSync.mockReturnValueOnce([]);
      fs.readdirSync.mockReturnValueOnce(['package.json']);
      inquirer.prompt.mockResolvedValueOnce({
        name: 'newbot',
      });
      await init();

      expect(error.mock.calls).toContainEqual([
        '  yarnpkg add --dev --silent nodemon has failed.',
      ]);
      expect(print.mock.calls).toContainEqual([
        'Deleting generated file... package.json',
      ]);
      expect(fs.removeSync).toBeCalledWith(path.join(path.resolve('newbot')));