Skip to content

Commit a85bf52

Browse files
committed
refactor: wip
1 parent e4f41d8 commit a85bf52

23 files changed

+112
-126
lines changed

packages/utils/src/lib/execute-process.int.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ process:complete
129129
throwError: true,
130130
}),
131131
),
132-
).rejects.toThrowError('Process failed with exit code 1');
132+
).rejects.toThrow('Process failed with exit code 1');
133133
expect(logger.debug).toHaveBeenCalledWith(
134134
expect.stringMatching(/process:start.*Error: dummy-error/s),
135135
{ force: true },

packages/utils/src/lib/exit-process.int.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('subscribeProcessExit', () => {
2525
});
2626

2727
it('should install event listeners for all expected events', () => {
28-
expect(() => subscribeProcessExit({ onError, onExit })).not.toThrowError();
28+
expect(() => subscribeProcessExit({ onError, onExit })).not.toThrow();
2929

3030
expect(processOnSpy).toHaveBeenCalledWith(
3131
'uncaughtException',
@@ -42,7 +42,7 @@ describe('subscribeProcessExit', () => {
4242
});
4343

4444
it('should call onError with error and kind for uncaughtException', () => {
45-
expect(() => subscribeProcessExit({ onError })).not.toThrowError();
45+
expect(() => subscribeProcessExit({ onError })).not.toThrow();
4646

4747
const testError = new Error('Test uncaught exception');
4848

@@ -56,7 +56,7 @@ describe('subscribeProcessExit', () => {
5656
});
5757

5858
it('should call onError with reason and kind for unhandledRejection', () => {
59-
expect(() => subscribeProcessExit({ onError })).not.toThrowError();
59+
expect(() => subscribeProcessExit({ onError })).not.toThrow();
6060

6161
const testReason = 'Test unhandled rejection';
6262

@@ -70,7 +70,7 @@ describe('subscribeProcessExit', () => {
7070
});
7171

7272
it('should call onExit and exit with code 0 for SIGINT', () => {
73-
expect(() => subscribeProcessExit({ onExit })).not.toThrowError();
73+
expect(() => subscribeProcessExit({ onExit })).not.toThrow();
7474

7575
(process as any).emit('SIGINT');
7676

@@ -82,7 +82,7 @@ describe('subscribeProcessExit', () => {
8282
});
8383

8484
it('should call onExit and exit with code 0 for SIGTERM', () => {
85-
expect(() => subscribeProcessExit({ onExit })).not.toThrowError();
85+
expect(() => subscribeProcessExit({ onExit })).not.toThrow();
8686

8787
(process as any).emit('SIGTERM');
8888

@@ -97,7 +97,7 @@ describe('subscribeProcessExit', () => {
9797
});
9898

9999
it('should call onExit and exit with code 0 for SIGQUIT', () => {
100-
expect(() => subscribeProcessExit({ onExit })).not.toThrowError();
100+
expect(() => subscribeProcessExit({ onExit })).not.toThrow();
101101

102102
(process as any).emit('SIGQUIT');
103103

@@ -112,7 +112,7 @@ describe('subscribeProcessExit', () => {
112112
});
113113

114114
it('should call onExit for successful process termination with exit code 0', () => {
115-
expect(() => subscribeProcessExit({ onExit })).not.toThrowError();
115+
expect(() => subscribeProcessExit({ onExit })).not.toThrow();
116116

117117
(process as any).emit('exit', 0);
118118

@@ -122,7 +122,7 @@ describe('subscribeProcessExit', () => {
122122
});
123123

124124
it('should call onExit for failed process termination with exit code 1', () => {
125-
expect(() => subscribeProcessExit({ onExit })).not.toThrowError();
125+
expect(() => subscribeProcessExit({ onExit })).not.toThrow();
126126

127127
(process as any).emit('exit', 1);
128128

packages/utils/src/lib/exit-process.unit.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('subscribeProcessExit', () => {
2626
});
2727

2828
it('should install event listeners for all expected events', () => {
29-
expect(() => subscribeProcessExit({ onError, onExit })).not.toThrowError();
29+
expect(() => subscribeProcessExit({ onError, onExit })).not.toThrow();
3030

3131
expect(processOnSpy).toHaveBeenCalledWith(
3232
'uncaughtException',
@@ -43,7 +43,7 @@ describe('subscribeProcessExit', () => {
4343
});
4444

4545
it('should call onError with error and kind for uncaughtException', () => {
46-
expect(() => subscribeProcessExit({ onError })).not.toThrowError();
46+
expect(() => subscribeProcessExit({ onError })).not.toThrow();
4747

4848
const testError = new Error('Test uncaught exception');
4949

@@ -57,7 +57,7 @@ describe('subscribeProcessExit', () => {
5757
});
5858

5959
it('should call onError with reason and kind for unhandledRejection', () => {
60-
expect(() => subscribeProcessExit({ onError })).not.toThrowError();
60+
expect(() => subscribeProcessExit({ onError })).not.toThrow();
6161

6262
const testReason = 'Test unhandled rejection';
6363

@@ -73,7 +73,7 @@ describe('subscribeProcessExit', () => {
7373
it('should call onExit with correct code and reason for SIGINT', () => {
7474
expect(() =>
7575
subscribeProcessExit({ onExit, exitOnSignal: true }),
76-
).not.toThrowError();
76+
).not.toThrow();
7777

7878
(process as any).emit('SIGINT');
7979

@@ -88,7 +88,7 @@ describe('subscribeProcessExit', () => {
8888
it('should call onExit with correct code and reason for SIGTERM', () => {
8989
expect(() =>
9090
subscribeProcessExit({ onExit, exitOnSignal: true }),
91-
).not.toThrowError();
91+
).not.toThrow();
9292

9393
(process as any).emit('SIGTERM');
9494

@@ -106,7 +106,7 @@ describe('subscribeProcessExit', () => {
106106
it('should call onExit with correct code and reason for SIGQUIT', () => {
107107
expect(() =>
108108
subscribeProcessExit({ onExit, exitOnSignal: true }),
109-
).not.toThrowError();
109+
).not.toThrow();
110110

111111
(process as any).emit('SIGQUIT');
112112

@@ -124,7 +124,7 @@ describe('subscribeProcessExit', () => {
124124
it('should not exit process when exitOnSignal is false', () => {
125125
expect(() =>
126126
subscribeProcessExit({ onExit, exitOnSignal: false }),
127-
).not.toThrowError();
127+
).not.toThrow();
128128

129129
(process as any).emit('SIGINT');
130130

@@ -137,7 +137,7 @@ describe('subscribeProcessExit', () => {
137137
});
138138

139139
it('should not exit process when exitOnSignal is not set', () => {
140-
expect(() => subscribeProcessExit({ onExit })).not.toThrowError();
140+
expect(() => subscribeProcessExit({ onExit })).not.toThrow();
141141

142142
(process as any).emit('SIGTERM');
143143

@@ -153,7 +153,7 @@ describe('subscribeProcessExit', () => {
153153
});
154154

155155
it('should call onExit with exit code and reason for normal exit', () => {
156-
expect(() => subscribeProcessExit({ onExit })).not.toThrowError();
156+
expect(() => subscribeProcessExit({ onExit })).not.toThrow();
157157

158158
const exitCode = 42;
159159
(process as any).emit('exit', exitCode);
@@ -166,7 +166,7 @@ describe('subscribeProcessExit', () => {
166166
it('should call onExit with fatal reason when exitOnFatal is true', () => {
167167
expect(() =>
168168
subscribeProcessExit({ onError, onExit, exitOnFatal: true }),
169-
).not.toThrowError();
169+
).not.toThrow();
170170

171171
const testError = new Error('Test uncaught exception');
172172

@@ -190,7 +190,7 @@ describe('subscribeProcessExit', () => {
190190
exitOnFatal: true,
191191
fatalExitCode: 42,
192192
}),
193-
).not.toThrowError();
193+
).not.toThrow();
194194

195195
const testError = new Error('Test uncaught exception');
196196

@@ -209,7 +209,7 @@ describe('subscribeProcessExit', () => {
209209
it('should call onExit with fatal reason for unhandledRejection when exitOnFatal is true', () => {
210210
expect(() =>
211211
subscribeProcessExit({ onError, onExit, exitOnFatal: true }),
212-
).not.toThrowError();
212+
).not.toThrow();
213213

214214
const testReason = 'Test unhandled rejection';
215215

@@ -254,7 +254,7 @@ describe('subscribeProcessExit', () => {
254254
it('should call onExit only once even when close is called multiple times', () => {
255255
expect(() =>
256256
subscribeProcessExit({ onExit, exitOnSignal: true }),
257-
).not.toThrowError();
257+
).not.toThrow();
258258

259259
(process as any).emit('SIGINT');
260260
expect(onExit).toHaveBeenCalledExactlyOnceWith(SIGNAL_EXIT_CODES().SIGINT, {

packages/utils/src/lib/file-system.int.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,19 @@ describe('importModule', () => {
4747
it('should throw if the file does not exist', async () => {
4848
await expect(
4949
importModule({ filepath: 'path/to/non-existent-export.mjs' }),
50-
).rejects.toThrowError(
51-
"File 'path/to/non-existent-export.mjs' does not exist",
52-
);
50+
).rejects.toThrow("File 'path/to/non-existent-export.mjs' does not exist");
5351
});
5452

5553
it('should throw if path is a directory', async () => {
56-
await expect(importModule({ filepath: mockDir })).rejects.toThrowError(
54+
await expect(importModule({ filepath: mockDir })).rejects.toThrow(
5755
`Expected '${mockDir}' to be a file`,
5856
);
5957
});
6058

6159
it('should throw if file is not valid JS', async () => {
6260
await expect(
6361
importModule({ filepath: path.join(mockDir, 'invalid-js-file.json') }),
64-
).rejects.toThrowError(
62+
).rejects.toThrow(
6563
`${path.join(mockDir, 'invalid-js-file.json')} is not a valid JS file`,
6664
);
6765
});

packages/utils/src/lib/git/git.commits-and-tags.int.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('getCurrentBranchOrTag', () => {
3232
it('getCurrentBranchOrTag should throw if no branch or tag is given', async () => {
3333
await expect(
3434
getCurrentBranchOrTag(currentBranchOrTagGitMock),
35-
).rejects.toThrowError('No names found, cannot describe anything');
35+
).rejects.toThrow('No names found, cannot describe anything');
3636
});
3737
});
3838

@@ -104,7 +104,7 @@ describe('getHashes', () => {
104104

105105
describe('without a branch and commits', () => {
106106
it('should throw', async () => {
107-
await expect(getHashes({}, gitMock)).rejects.toThrowError(
107+
await expect(getHashes({}, gitMock)).rejects.toThrow(
108108
"your current branch 'main' does not have any commits yet",
109109
);
110110
});
@@ -165,7 +165,7 @@ describe('getHashes', () => {
165165
it('should throw if "from" is undefined but "to" is defined', async () => {
166166
await expect(
167167
getHashes({ from: undefined, to: 'a' }, gitMock),
168-
).rejects.toThrowError(
168+
).rejects.toThrow(
169169
'filter needs the "from" option defined to accept the "to" option.',
170170
);
171171
});

packages/utils/src/lib/git/git.commits-and-tags.unit.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('filterLogs', () => {
5353
});
5454

5555
it('should throw for "to" without "from" filter', () => {
56-
expect(() => filterLogs([], { to: 'e' })).toThrowError(
56+
expect(() => filterLogs([], { to: 'e' })).toThrow(
5757
'filter needs the "from" option defined to accept the "to" option.',
5858
);
5959
});
@@ -163,9 +163,7 @@ describe('getSemverTags', () => {
163163
});
164164

165165
it('should throw if "from" is undefined but "to" is defined', async () => {
166-
await expect(
167-
getSemverTags({ from: undefined, to: 'a' }),
168-
).rejects.toThrowError(
166+
await expect(getSemverTags({ from: undefined, to: 'a' })).rejects.toThrow(
169167
'filter needs the "from" option defined to accept the "to" option',
170168
);
171169
});

packages/utils/src/lib/git/git.int.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('git utils in a git repo', () => {
8282
it('safeCheckout should throw if a given branch does not exist', async () => {
8383
await expect(
8484
safeCheckout('non-existing-branch', undefined, emptyGit),
85-
).rejects.toThrowError(
85+
).rejects.toThrow(
8686
"pathspec 'non-existing-branch' did not match any file(s) known to git",
8787
);
8888
});
@@ -133,9 +133,7 @@ describe('git utils in a git repo', () => {
133133
});
134134

135135
it('safeCheckout should throw if history is dirty', async () => {
136-
await expect(
137-
safeCheckout('master', undefined, emptyGit),
138-
).rejects.toThrowError(
136+
await expect(safeCheckout('master', undefined, emptyGit)).rejects.toThrow(
139137
`Working directory needs to be clean before we you can proceed. Commit your local changes or stash them: \n ${JSON.stringify(
140138
{
141139
not_added: ['new-file.md'],

packages/utils/src/lib/git/git.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('guardAgainstLocalChanges', () => {
1111
guardAgainstLocalChanges({
1212
status: () => Promise.resolve({ files: [''] }),
1313
} as unknown as SimpleGit),
14-
).rejects.toThrowError(
14+
).rejects.toThrow(
1515
new GitStatusError({ files: [''] } as unknown as StatusResult),
1616
);
1717
});

packages/utils/src/lib/logger.int.test.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ ${ansis.red('Failed to load config')}
159159
"ENOENT: no such file or directory, open '.code-pushup/eslint/results.json'",
160160
);
161161
}),
162-
).rejects.toThrowError(
162+
).rejects.toThrow(
163163
"ENOENT: no such file or directory, open '.code-pushup/eslint/results.json'",
164164
);
165165
expect(stdout).toBe(
@@ -349,7 +349,7 @@ ${ansis.magenta('└')} ${ansis.green(`Total line coverage is ${ansis.bold('82%'
349349

350350
expect(stdout).toBe(`${ansis.cyan('⠋')} Uploading report to portal`);
351351

352-
await expect(task).rejects.toThrowError('GraphQL error: Invalid API key');
352+
await expect(task).rejects.toThrow('GraphQL error: Invalid API key');
353353

354354
expect(stdout).toBe(
355355
`${ansis.red('✖')} Uploading report to portal → ${ansis.red('GraphQL error: Invalid API key')}\n`,
@@ -502,7 +502,7 @@ ${ansis.green('✔')} Uploaded report to portal ${ansis.gray('(42 ms)')}
502502
expect(stdout).toBe(`${ansis.cyan('⠋')} Uploading report to portal`);
503503

504504
vi.advanceTimersByTime(42);
505-
await expect(task).rejects.toThrowError('GraphQL error: Invalid API key');
505+
await expect(task).rejects.toThrow('GraphQL error: Invalid API key');
506506

507507
expect(stdout).toBe(
508508
`
@@ -575,9 +575,7 @@ ${ansis.red('✖')} Uploading report to portal → ${ansis.red('GraphQL error: I
575575
`${ansis.cyan('⠋')} ${ansis.blue('$')} npx eslint . --format=json`,
576576
);
577577

578-
await expect(command).rejects.toThrowError(
579-
'Process failed with exit code 1',
580-
);
578+
await expect(command).rejects.toThrow('Process failed with exit code 1');
581579

582580
expect(stdout).toBe(
583581
`${ansis.red('✖')} ${ansis.red('$')} npx eslint . --format=json\n`,
@@ -833,9 +831,7 @@ ${ansis.cyan('-')} ${ansis.blue('$')} npx eslint . --format=json`,
833831
);
834832

835833
vi.advanceTimersToNextTimer();
836-
await expect(group).rejects.toThrowError(
837-
'Process failed with exit code 1',
838-
);
834+
await expect(group).rejects.toThrow('Process failed with exit code 1');
839835

840836
expect(stdout).toBe(
841837
`
@@ -924,9 +920,7 @@ ${ansis.red.bold('Cancelled by SIGINT')}
924920
return 'ESLint reported 0 problems';
925921
});
926922

927-
await expect(group).rejects.toThrowError(
928-
'Process failed with exit code 2',
929-
);
923+
await expect(group).rejects.toThrow('Process failed with exit code 2');
930924

931925
expect(ansis.strip(stdout)).toBe(
932926
`
@@ -956,7 +950,7 @@ ${ansis.red.bold('Cancelled by SIGINT')}
956950
await logger.group('Inner group', async () => 'Inner group complete');
957951
return 'Outer group complete';
958952
}),
959-
).rejects.toThrowError(
953+
).rejects.toThrow(
960954
'Internal Logger error - nested groups are not supported',
961955
);
962956
});
@@ -969,7 +963,7 @@ ${ansis.red.bold('Cancelled by SIGINT')}
969963
await logger.group('Some group', async () => 'Group completed');
970964
return 'Async process completed';
971965
}),
972-
).rejects.toThrowError(
966+
).rejects.toThrow(
973967
'Internal Logger error - creating group in active spinner is not supported',
974968
);
975969
});
@@ -982,7 +976,7 @@ ${ansis.red.bold('Cancelled by SIGINT')}
982976
logger.task('Task 1', async () => 'DONE'),
983977
logger.task('Task 2', async () => 'DONE'),
984978
]),
985-
).rejects.toThrowError(
979+
).rejects.toThrow(
986980
'Internal Logger error - concurrent spinners are not supported',
987981
);
988982
});
@@ -996,7 +990,7 @@ ${ansis.red.bold('Cancelled by SIGINT')}
996990
await logger.task('Task 2', async () => 'DONE');
997991
return 'DONE';
998992
}),
999-
).rejects.toThrowError(
993+
).rejects.toThrow(
1000994
'Internal Logger error - concurrent spinners are not supported',
1001995
);
1002996
});

0 commit comments

Comments
 (0)