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 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')));