Skip to content

Commit 1b7b4db

Browse files
robstrykerclaude
andcommitted
Fixes #249 - Add retry logic for flaky extension UI test
The extension installed UI test was failing ~50% of the time with StaleElementReferenceError when trying to get the extension title. Root cause: Between finding the extension item and calling getTitle(), VS Code can refresh the extensions list DOM, making the element reference stale. Solution: Add retry logic that: - Catches StaleElementReferenceError - Retries the entire operation (find + getTitle) up to 3 times - Waits 500ms between retries to allow DOM to stabilize - Re-throws if it's a different error or retries are exhausted This should eliminate the flakiness while maintaining test reliability. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 9a4b1b0 commit 1b7b4db

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

vscode/test/ui-test/extensionInstalledUITest.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,32 @@ export function extensionInstalledUITest(): void {
2121

2222
it('RSP server community extension is installed', async function () {
2323
this.timeout(20000);
24-
const item = (await section.findItem(`@installed ` + AdaptersConstants.RSP_EXTENSTION_NAME)) as ExtensionsViewItem;
25-
expect(item).not.undefined;
26-
expect(await item.getTitle()).to.equal(AdaptersConstants.RSP_EXTENSTION_NAME);
24+
25+
// Retry logic to handle StaleElementReferenceError
26+
const maxRetries = 3;
27+
let lastError: Error | undefined;
28+
29+
for (let attempt = 0; attempt < maxRetries; attempt++) {
30+
try {
31+
const item = (await section.findItem(`@installed ` + AdaptersConstants.RSP_EXTENSTION_NAME)) as ExtensionsViewItem;
32+
expect(item).not.undefined;
33+
const title = await item.getTitle();
34+
expect(title).to.equal(AdaptersConstants.RSP_EXTENSTION_NAME);
35+
return; // Success, exit the test
36+
} catch (error: any) {
37+
lastError = error;
38+
if (error.name === 'StaleElementReferenceError' && attempt < maxRetries - 1) {
39+
// Wait a bit before retrying
40+
await new Promise(resolve => setTimeout(resolve, 500));
41+
continue;
42+
}
43+
// If it's not a stale element error, or we're out of retries, throw
44+
throw error;
45+
}
46+
}
47+
48+
// If we get here, all retries failed
49+
throw lastError!;
2750
});
2851

2952
afterEach(async function () {

0 commit comments

Comments
 (0)