Skip to content

Commit b689ebb

Browse files
committed
fix: resolve test conflicts with retry logic …
- Remove test.only to run all tests - Create dedicated client instance with retry disabled for rate limit tests - Fix Jest exit issues with proper cleanup - Remove debug console.log statements
1 parent 737366b commit b689ebb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

nodejs/tests/api.spec.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ afterEach(() => {
1616
})
1717

1818
afterAll(() => {
19-
return server.close()
19+
server.close()
20+
// Add explicit cleanup to ensure Jest exits properly
21+
return new Promise(resolve => setTimeout(resolve, 100))
2022
})
2123

2224
test('getMe', async () => {
@@ -56,7 +58,13 @@ test('should throw axios error object if set wrapResponseErrors to false', async
5658
}
5759
})
5860

59-
test.only('should throw HackMD error object', async () => {
61+
test('should throw HackMD error object', async () => {
62+
// Create a client with retry disabled to avoid conflicts with error handling test
63+
const clientWithoutRetry = new API(process.env.HACKMD_ACCESS_TOKEN!, undefined, {
64+
wrapResponseErrors: true,
65+
retryConfig: undefined // Disable retry logic for this test
66+
})
67+
6068
server.use(
6169
rest.get('https://api.hackmd.io/v1/me', (req, res, ctx) => {
6270
return res(
@@ -73,12 +81,11 @@ test.only('should throw HackMD error object', async () => {
7381
)
7482

7583
try {
76-
await client.getMe()
84+
await clientWithoutRetry.getMe()
85+
// If we get here, the test should fail because an error wasn't thrown
86+
expect('no error thrown').toBe('error should have been thrown')
7787
} catch (error: any) {
7888
expect(error).toBeInstanceOf(TooManyRequestsError)
79-
80-
console.log(JSON.stringify(error))
81-
8289
expect(error).toHaveProperty('code', 429)
8390
expect(error).toHaveProperty('statusText', 'Too Many Requests')
8491
expect(error).toHaveProperty('userLimit', 100)

0 commit comments

Comments
 (0)