Skip to content

Commit 392747f

Browse files
committed
TS errors in tests fixed
1 parent 2cb8537 commit 392747f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

test/client.error.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ describe('Advanced/Edge Cases: Custom Errors', () => {
165165
await f('https://example.com')
166166
} catch (err) {
167167
expect(err).toBeInstanceOf(RetryLimitError)
168-
expect(err.message).toBe('something bad')
168+
if (err instanceof Error) {
169+
expect(err.message).toBe('something bad')
170+
}
169171
}
170172
})
171173

@@ -237,7 +239,9 @@ describe('Advanced/Edge Cases: Custom Errors', () => {
237239
await f('https://example.com')
238240
} catch (err) {
239241
expect(err).toBeInstanceOf(RetryLimitError)
240-
expect(err.message).toBe('Retry limit reached')
242+
if (err instanceof Error) {
243+
expect(err.message).toBe('Retry limit reached')
244+
}
241245
}
242246
})
243247
})

test/client.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ it('aborts after 50 ms', async () => {
1919
throw new Error('Expected AbortError to be thrown')
2020
} catch (err) {
2121
expect(err).toBeInstanceOf(Error)
22-
expect(err.name).toBe('AbortError')
23-
expect(err.message).toBe('Request was aborted by user')
22+
if (err instanceof Error) {
23+
expect(err.name).toBe('AbortError')
24+
expect(err.message).toBe('Request was aborted by user')
25+
}
2426
}
2527
})
2628

@@ -85,9 +87,11 @@ it('throws AbortError with message "Request was aborted" when timeout signal abo
8587
await client('https://example.com')
8688
throw new Error('Expected AbortError to be thrown')
8789
} catch (err) {
88-
expect(err.constructor.name).toBe('AbortError')
89-
expect(err.name).toBe('AbortError')
90-
expect(err.message).toBe('Request was aborted')
90+
if (err instanceof Error) {
91+
expect(err.constructor.name).toBe('AbortError')
92+
expect(err.name).toBe('AbortError')
93+
expect(err.message).toBe('Request was aborted')
94+
}
9195
} finally {
9296
// Restore throwIfAborted
9397
AbortSignal.prototype.throwIfAborted = origThrowIfAborted

0 commit comments

Comments
 (0)