forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmockRushCommandLineParser.ts
More file actions
23 lines (20 loc) · 938 Bytes
/
mockRushCommandLineParser.ts
File metadata and controls
23 lines (20 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
// Mock child_process so we can verify tasks are (or are not) invoked as we expect
jest.mock('child_process');
function mockReportErrorAndSetExitCode(error: Error): void {
// Just rethrow the error so the unit tests can catch it
throw error;
}
/**
* Mock RushCommandLineParser itself to prevent `process.exit` to be called on failure
*/
jest.mock('../RushCommandLineParser', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const actualModule: any = require.requireActual('../RushCommandLineParser');
if (actualModule.RushCommandLineParser) {
// Stub out the troublesome method that calls `process.exit`
actualModule.RushCommandLineParser.prototype._reportErrorAndSetExitCode = mockReportErrorAndSetExitCode;
}
return actualModule;
});