Skip to content

Commit 5d898ce

Browse files
w01fgangclaude
andcommitted
chore: fix pre-existing lint + typecheck errors in Try.test.ts
- Rename deprecated toBeCalledWith → toHaveBeenCalledWith (14) - Type mockAddBreadcrumbs via Reporter['addBreadcrumbs'] - Disable only-throw-error for intentional non-Error throw tests (4) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f5c487c commit 5d898ce

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

src/__tests__/Try.test.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ describe('Try', () => {
273273
const expectedError = new Error('failed');
274274
expectedError.cause = new Error('boom');
275275

276-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
276+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
277277
tags: {
278278
library: '@power-rent/try-catch',
279279
name: 'value',
@@ -301,7 +301,7 @@ describe('Try', () => {
301301
const expectedError = new Error('failed');
302302
expectedError.cause = new Error('boom');
303303

304-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
304+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
305305
tags: {
306306
library: '@power-rent/try-catch',
307307
component: 'payment-service',
@@ -328,7 +328,7 @@ describe('Try', () => {
328328
const expectedError = new Error('failed');
329329
expectedError.cause = new Error('boom');
330330

331-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
331+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
332332
tags: {
333333
library: '@power-rent/try-catch',
334334
module: 'data-processor',
@@ -354,7 +354,7 @@ describe('Try', () => {
354354
const expectedError = new Error('failed');
355355
expectedError.cause = new Error('boom');
356356

357-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
357+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
358358
tags: {
359359
library: '@power-rent/try-catch',
360360
version: '2.0', // overridden value
@@ -379,7 +379,7 @@ describe('Try', () => {
379379
const expectedError = new Error('failed');
380380
expectedError.cause = new Error('boom');
381381

382-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
382+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
383383
tags: {
384384
library: '@power-rent/try-catch',
385385
single: 'tag',
@@ -843,7 +843,7 @@ describe('Try', () => {
843843
const expectedError = new Error('failed');
844844
expectedError.cause = new Error('boom');
845845

846-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
846+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
847847
tags: {
848848
library: '@power-rent/try-catch',
849849
component: 'test',
@@ -884,7 +884,7 @@ describe('Try', () => {
884884
const expectedError = new Error('failed');
885885
expectedError.cause = new Error('boom');
886886

887-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
887+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
888888
tags: {
889889
library: '@power-rent/try-catch',
890890
component: 'payment',
@@ -1112,7 +1112,7 @@ describe('Try', () => {
11121112
const expectedError = new Error('failed');
11131113
expectedError.cause = new Error('boom');
11141114

1115-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
1115+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
11161116
tags: {
11171117
library: '@power-rent/try-catch',
11181118
name: 'value',
@@ -1140,7 +1140,7 @@ describe('Try', () => {
11401140
const expectedError = new Error('failed');
11411141
expectedError.cause = new Error('boom');
11421142

1143-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
1143+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
11441144
tags: {
11451145
library: '@power-rent/try-catch',
11461146
component: 'payment-service',
@@ -1167,7 +1167,7 @@ describe('Try', () => {
11671167
const expectedError = new Error('failed');
11681168
expectedError.cause = new Error('boom');
11691169

1170-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
1170+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
11711171
tags: {
11721172
library: '@power-rent/try-catch',
11731173
module: 'data-processor',
@@ -1193,7 +1193,7 @@ describe('Try', () => {
11931193
const expectedError = new Error('failed');
11941194
expectedError.cause = new Error('boom');
11951195

1196-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
1196+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
11971197
tags: {
11981198
library: '@power-rent/try-catch',
11991199
version: '2.0', // overridden value
@@ -1218,7 +1218,7 @@ describe('Try', () => {
12181218
const expectedError = new Error('failed');
12191219
expectedError.cause = new Error('boom');
12201220

1221-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
1221+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
12221222
tags: {
12231223
library: '@power-rent/try-catch',
12241224
single: 'tag',
@@ -1650,7 +1650,7 @@ describe('Try', () => {
16501650
const expectedError = new Error('failed');
16511651
expectedError.cause = new Error('boom');
16521652

1653-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
1653+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
16541654
tags: {
16551655
library: '@power-rent/try-catch',
16561656
component: 'test',
@@ -1691,7 +1691,7 @@ describe('Try', () => {
16911691
const expectedError = new Error('failed');
16921692
expectedError.cause = new Error('boom');
16931693

1694-
expect(Sentry.captureException).toBeCalledWith(expectedError, {
1694+
expect(Sentry.captureException).toHaveBeenCalledWith(expectedError, {
16951695
tags: {
16961696
library: '@power-rent/try-catch',
16971697
component: 'payment',
@@ -1809,6 +1809,7 @@ describe('Try', () => {
18091809

18101810
describe('non-Error normalization (DIAG-01)', () => {
18111811
it('sync: thrown string is normalized to Error with cause', async () => {
1812+
// eslint-disable-next-line @typescript-eslint/only-throw-error
18121813
const result = new Try(() => { throw 'oops'; }).result();
18131814
expect(result).not.toBeInstanceOf(Promise);
18141815
const r = result as { success: false; error: Error };
@@ -1818,6 +1819,7 @@ describe('Try', () => {
18181819
});
18191820

18201821
it('sync: thrown number is normalized to Error with cause', () => {
1822+
// eslint-disable-next-line @typescript-eslint/only-throw-error
18211823
const result = new Try(() => { throw 42; }).result();
18221824
const r = result as { success: false; error: Error };
18231825
expect(r.error).toBeInstanceOf(Error);
@@ -1827,6 +1829,7 @@ describe('Try', () => {
18271829

18281830
it('sync: thrown plain object is normalized to Error with cause', () => {
18291831
const obj = { code: 42 };
1832+
// eslint-disable-next-line @typescript-eslint/only-throw-error
18301833
const result = new Try(() => { throw obj; }).result();
18311834
const r = result as { success: false; error: Error };
18321835
expect(r.error).toBeInstanceOf(Error);
@@ -1835,6 +1838,7 @@ describe('Try', () => {
18351838
});
18361839

18371840
it('async: rejected string is normalized to Error with cause', async () => {
1841+
// eslint-disable-next-line @typescript-eslint/only-throw-error
18381842
const result = await new Try(async () => { throw 'oops'; }).result();
18391843
expect(result.success).toBe(false);
18401844
if (!result.success) {
@@ -1864,7 +1868,7 @@ describe('Try', () => {
18641868
});
18651869

18661870
describe('breadcrumb consistency (SENT-03, D-06)', () => {
1867-
let mockAddBreadcrumbs: ReturnType<typeof vi.fn>;
1871+
let mockAddBreadcrumbs: import('../core/reporter').Reporter['addBreadcrumbs'];
18681872
let savedReporter: import('../core/reporter').Reporter;
18691873

18701874
beforeEach(() => {

0 commit comments

Comments
 (0)