-
-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(webpack-cli): handle promise rejection with package installation (#…
…1284) * fix: handle promise rejection * chore: better message * chore: test case for prompt-installation
- Loading branch information
1 parent
b93ffe4
commit eb1112e
Showing
2 changed files
with
16 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
'use strict'; | ||
|
||
import { packageExists } from '../src'; | ||
jest.mock('@webpack-cli/package-utils') | ||
|
||
import { packageExists, promptInstallation } from '@webpack-cli/package-utils'; | ||
import ExternalCommand from '../../webpack-cli/lib/commands/ExternalCommand'; | ||
|
||
describe('@webpack-cli/package-utils', () => { | ||
it('should check existence of package', () => { | ||
(packageExists as any).mockImplementation(() => true); | ||
const exists = packageExists('@webpack-cli/info'); | ||
|
||
expect(exists).toBeTruthy(); | ||
}); | ||
|
||
it('should not throw if the user interrupts', async () => { | ||
(promptInstallation as any).mockImplementation(() => { throw new Error() }); | ||
await expect(ExternalCommand.run('info')).resolves.not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters