Skip to content

Commit be90c25

Browse files
committed
chore: add retries to a flaky test that depends on timeouts
1 parent 1039f4e commit be90c25

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

tests/integration/resources/exportedData.test.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,23 @@ describeWithMongoDB(
7474
expect(exportedResourceURI).toBeDefined();
7575

7676
// wait for export expired
77-
await timeout(300);
78-
const response = await integration.mcpClient().readResource({
79-
uri: exportedResourceURI as string,
80-
});
81-
expect(response.isError).toEqual(true);
82-
expect(response.contents[0]?.uri).toEqual(exportedResourceURI);
83-
expect(response.contents[0]?.text).toMatch(`Error reading ${exportedResourceURI}:`);
77+
for (let tries = 0; tries < 10; tries++) {
78+
await timeout(300);
79+
const response = await integration.mcpClient().readResource({
80+
uri: exportedResourceURI as string,
81+
});
82+
83+
// wait for an error from the MCP Server as it
84+
// means the resource is not available anymore
85+
if (response.isError === false) {
86+
continue;
87+
}
88+
89+
expect(response.isError).toEqual(true);
90+
expect(response.contents[0]?.uri).toEqual(exportedResourceURI);
91+
expect(response.contents[0]?.text).toMatch(`Error reading ${exportedResourceURI}:`);
92+
break;
93+
}
8494
});
8595
});
8696

0 commit comments

Comments
 (0)