Skip to content

Commit cc7b98b

Browse files
committed
refactor: wip
1 parent 55b26fe commit cc7b98b

11 files changed

+95
-55
lines changed

packages/utils/mocks/omit-trace-json.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,11 @@ const uniq = <T>(v: (T | undefined)[]) => [
8888
];
8989
const ctx = (e: TraceEvent[], base = BASE_TS) => ({
9090
pid: new Map(
91-
[...uniq(e.map(x => x.pid))]
92-
.sort()
93-
.map((v, i) => [v, 10_001 + i]),
94-
),
95-
tid: new Map(
96-
[...uniq(e.map(x => x.tid))]
97-
.sort()
98-
.map((v, i) => [v, i + 1]),
91+
[...uniq(e.map(x => x.pid))].sort().map((v, i) => [v, 10_001 + i]),
9992
),
93+
tid: new Map([...uniq(e.map(x => x.tid))].sort().map((v, i) => [v, i + 1])),
10094
ts: new Map(
101-
[...uniq(e.map(x => x.ts))]
102-
.sort()
103-
.map((v, i) => [v, base + i * 100]),
95+
[...uniq(e.map(x => x.ts))].sort().map((v, i) => [v, base + i * 100]),
10496
),
10597
id: new Map(
10698
[...uniq(e.map(x => x.id2?.local))]

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ describe('subscribeProcessExit', () => {
4848

4949
(process as any).emit('uncaughtException', testError);
5050

51-
expect(onError).toHaveBeenCalledExactlyOnceWith(testError, 'uncaughtException');
51+
expect(onError).toHaveBeenCalledExactlyOnceWith(
52+
testError,
53+
'uncaughtException',
54+
);
5255
expect(onExit).not.toHaveBeenCalled();
5356
});
5457

@@ -59,7 +62,10 @@ describe('subscribeProcessExit', () => {
5962

6063
(process as any).emit('unhandledRejection', testReason);
6164

62-
expect(onError).toHaveBeenCalledExactlyOnceWith(testReason, 'unhandledRejection');
65+
expect(onError).toHaveBeenCalledExactlyOnceWith(
66+
testReason,
67+
'unhandledRejection',
68+
);
6369
expect(onExit).not.toHaveBeenCalled();
6470
});
6571

@@ -80,10 +86,13 @@ describe('subscribeProcessExit', () => {
8086

8187
(process as any).emit('SIGTERM');
8288

83-
expect(onExit).toHaveBeenCalledExactlyOnceWith(SIGNAL_EXIT_CODES().SIGTERM, {
84-
kind: 'signal',
85-
signal: 'SIGTERM',
86-
});
89+
expect(onExit).toHaveBeenCalledExactlyOnceWith(
90+
SIGNAL_EXIT_CODES().SIGTERM,
91+
{
92+
kind: 'signal',
93+
signal: 'SIGTERM',
94+
},
95+
);
8796
expect(onError).not.toHaveBeenCalled();
8897
});
8998

@@ -92,10 +101,13 @@ describe('subscribeProcessExit', () => {
92101

93102
(process as any).emit('SIGQUIT');
94103

95-
expect(onExit).toHaveBeenCalledExactlyOnceWith(SIGNAL_EXIT_CODES().SIGQUIT, {
96-
kind: 'signal',
97-
signal: 'SIGQUIT',
98-
});
104+
expect(onExit).toHaveBeenCalledExactlyOnceWith(
105+
SIGNAL_EXIT_CODES().SIGQUIT,
106+
{
107+
kind: 'signal',
108+
signal: 'SIGQUIT',
109+
},
110+
);
99111
expect(onError).not.toHaveBeenCalled();
100112
});
101113

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

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ describe('subscribeProcessExit', () => {
4949

5050
(process as any).emit('uncaughtException', testError);
5151

52-
expect(onError).toHaveBeenCalledExactlyOnceWith(testError, 'uncaughtException');
52+
expect(onError).toHaveBeenCalledExactlyOnceWith(
53+
testError,
54+
'uncaughtException',
55+
);
5356
expect(onExit).not.toHaveBeenCalled();
5457
});
5558

@@ -60,7 +63,10 @@ describe('subscribeProcessExit', () => {
6063

6164
(process as any).emit('unhandledRejection', testReason);
6265

63-
expect(onError).toHaveBeenCalledExactlyOnceWith(testReason, 'unhandledRejection');
66+
expect(onError).toHaveBeenCalledExactlyOnceWith(
67+
testReason,
68+
'unhandledRejection',
69+
);
6470
expect(onExit).not.toHaveBeenCalled();
6571
});
6672

@@ -86,10 +92,13 @@ describe('subscribeProcessExit', () => {
8692

8793
(process as any).emit('SIGTERM');
8894

89-
expect(onExit).toHaveBeenCalledExactlyOnceWith(SIGNAL_EXIT_CODES().SIGTERM, {
90-
kind: 'signal',
91-
signal: 'SIGTERM',
92-
});
95+
expect(onExit).toHaveBeenCalledExactlyOnceWith(
96+
SIGNAL_EXIT_CODES().SIGTERM,
97+
{
98+
kind: 'signal',
99+
signal: 'SIGTERM',
100+
},
101+
);
93102
expect(onError).not.toHaveBeenCalled();
94103
expect(processExitSpy).toHaveBeenCalledWith(SIGNAL_EXIT_CODES().SIGTERM);
95104
});
@@ -101,10 +110,13 @@ describe('subscribeProcessExit', () => {
101110

102111
(process as any).emit('SIGQUIT');
103112

104-
expect(onExit).toHaveBeenCalledExactlyOnceWith(SIGNAL_EXIT_CODES().SIGQUIT, {
105-
kind: 'signal',
106-
signal: 'SIGQUIT',
107-
});
113+
expect(onExit).toHaveBeenCalledExactlyOnceWith(
114+
SIGNAL_EXIT_CODES().SIGQUIT,
115+
{
116+
kind: 'signal',
117+
signal: 'SIGQUIT',
118+
},
119+
);
108120
expect(onError).not.toHaveBeenCalled();
109121
expect(processExitSpy).toHaveBeenCalledWith(SIGNAL_EXIT_CODES().SIGQUIT);
110122
});
@@ -129,10 +141,13 @@ describe('subscribeProcessExit', () => {
129141

130142
(process as any).emit('SIGTERM');
131143

132-
expect(onExit).toHaveBeenCalledExactlyOnceWith(SIGNAL_EXIT_CODES().SIGTERM, {
133-
kind: 'signal',
134-
signal: 'SIGTERM',
135-
});
144+
expect(onExit).toHaveBeenCalledExactlyOnceWith(
145+
SIGNAL_EXIT_CODES().SIGTERM,
146+
{
147+
kind: 'signal',
148+
signal: 'SIGTERM',
149+
},
150+
);
136151
expect(onError).not.toHaveBeenCalled();
137152
expect(processExitSpy).not.toHaveBeenCalled();
138153
});
@@ -157,7 +172,10 @@ describe('subscribeProcessExit', () => {
157172

158173
(process as any).emit('uncaughtException', testError);
159174

160-
expect(onError).toHaveBeenCalledExactlyOnceWith(testError, 'uncaughtException');
175+
expect(onError).toHaveBeenCalledExactlyOnceWith(
176+
testError,
177+
'uncaughtException',
178+
);
161179
expect(onExit).toHaveBeenCalledExactlyOnceWith(1, {
162180
kind: 'fatal',
163181
fatal: 'uncaughtException',
@@ -178,7 +196,10 @@ describe('subscribeProcessExit', () => {
178196

179197
(process as any).emit('uncaughtException', testError);
180198

181-
expect(onError).toHaveBeenCalledExactlyOnceWith(testError, 'uncaughtException');
199+
expect(onError).toHaveBeenCalledExactlyOnceWith(
200+
testError,
201+
'uncaughtException',
202+
);
182203
expect(onExit).toHaveBeenCalledExactlyOnceWith(42, {
183204
kind: 'fatal',
184205
fatal: 'uncaughtException',
@@ -194,7 +215,10 @@ describe('subscribeProcessExit', () => {
194215

195216
(process as any).emit('unhandledRejection', testReason);
196217

197-
expect(onError).toHaveBeenCalledExactlyOnceWith(testReason, 'unhandledRejection');
218+
expect(onError).toHaveBeenCalledExactlyOnceWith(
219+
testReason,
220+
'unhandledRejection',
221+
);
198222
expect(onExit).toHaveBeenCalledExactlyOnceWith(1, {
199223
kind: 'fatal',
200224
fatal: 'unhandledRejection',

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ 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("File 'path/to/non-existent-export.mjs' does not exist");
50+
).rejects.toThrowError(
51+
"File 'path/to/non-existent-export.mjs' does not exist",
52+
);
5153
});
5254

5355
it('should throw if path is a directory', async () => {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ describe('getSemverTags', () => {
163163
});
164164

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

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ describe('git utils in a git repo', () => {
133133
});
134134

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

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,9 @@ ${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('Process failed with exit code 1');
578+
await expect(command).rejects.toThrowError(
579+
'Process failed with exit code 1',
580+
);
579581

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

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

836840
expect(stdout).toBe(
837841
`
@@ -920,7 +924,9 @@ ${ansis.red.bold('Cancelled by SIGINT')}
920924
return 'ESLint reported 0 problems';
921925
});
922926

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

925931
expect(ansis.strip(stdout)).toBe(
926932
`

packages/utils/src/lib/plugin-url-config.unit.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ describe('pluginUrlContextSchema', () => {
144144
[{ urlCount: 2 }, /expected record/i],
145145
[{ urlCount: 2, weights: { 1: 1 } }, /weights count must match/i],
146146
])('should throw error for invalid context: %j', (pattern, expectedError) => {
147-
expect(() => pluginUrlContextSchema.parse(pattern)).toThrowError(expectedError);
147+
expect(() => pluginUrlContextSchema.parse(pattern)).toThrowError(
148+
expectedError,
149+
);
148150
});
149151

150152
it('should accept valid context', () => {

packages/utils/src/lib/profiler/profiler-node.unit.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,11 @@ describe('NodejsProfiler', () => {
532532
});
533533

534534
const error = new Error('Async test error');
535-
await expect(profiler.measureAsync('async-error-test', async () => {
535+
await expect(
536+
profiler.measureAsync('async-error-test', async () => {
536537
throw error;
537-
})).rejects.toThrowError(error);
538+
}),
539+
).rejects.toThrowError(error);
538540
});
539541

540542
it('should skip measurement when profiler is not active', () => {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@ describe('Profiler', () => {
339339
throw error;
340340
});
341341

342-
expect(() => enabledProfiler.measure('test-event-error', workFn)).toThrowError(
343-
error,
344-
);
342+
expect(() =>
343+
enabledProfiler.measure('test-event-error', workFn),
344+
).toThrowError(error);
345345
expect(workFn).toHaveBeenCalled();
346346

347347
// Verify that performance marks were created even though error occurred

0 commit comments

Comments
 (0)