diff --git a/packages/package-utils/__tests__/index.test.ts b/packages/package-utils/__tests__/index.test.ts index bb67a82eae2..e16ce0d85ba 100644 --- a/packages/package-utils/__tests__/index.test.ts +++ b/packages/package-utils/__tests__/index.test.ts @@ -1,11 +1,19 @@ 'use strict'; -import { packageExists } from '../src'; +import * as packageUtils from '../src'; +import ExternalCommand from '../../webpack-cli/lib/commands/ExternalCommand'; + +const mock = jest.spyOn(packageUtils, 'promptInstallation') +mock.mockImplementation(() => { throw new Error() }) describe('@webpack-cli/package-utils', () => { it('should check existence of package', () => { - const exists = packageExists('@webpack-cli/info'); + const exists = packageUtils.packageExists('@webpack-cli/info'); expect(exists).toBeTruthy(); }); + + it('should not throw if the user interrupts', async () => { + await expect(ExternalCommand.run('@webpack-cli/info')).resolves.not.toThrow(); + }); });