Skip to content

Commit caa11b8

Browse files
Fix flaky VSCode extension E2E tests due to silently ignored timeout option (#19309)
The E2E test suite intermittently failed because `timeoutMs` passed to `until()` was silently dropped — `retryWhile` looked for `timeout`, not `timeoutMs` — capping all `until()` waits at the 10s default regardless of what callers specified. This caused `deploypane` tests (which intended a 30s webview-ready timeout) to flake whenever CI was slow. ## Changes - **`src/test/utils/time.ts`**: Rename `timeout` → `timeoutMs` in `retryWhile`'s options type so it matches the `until()` API: ```ts // Before — `timeoutMs` from callers was silently ignored retryOptions?: Readonly<{ interval?: number; timeout?: number }> // After — consistent naming across retryWhile and until retryOptions?: Readonly<{ interval?: number; timeoutMs?: number }> ``` - **`deploypane.test.ts`**: Add `jest.setTimeout(60000)` — now that `timeoutMs: 30000` actually works, the global 20s jest timeout would be exceeded (2s language server wait + up to 30s webview-ready poll). - **`visualizer.test.ts`**: Add explicit `timeoutMs: 20000` to all three `until()` calls (previously relied on the 10s default) and `jest.setTimeout(30000)` to match. - **`testReporter.ts`**: Fix the `Tests:` summary line, which was incorrectly reporting test-suite counts (`numPassedTestSuites` / `numTotalTestSuites`) instead of individual test counts (`numPassedTests` / `numTotalTests`). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
1 parent 932191a commit caa11b8

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/vscode-bicep/src/test/e2e/deploypane.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { resolveExamplePath } from "./examples";
1313

1414
const extensionLogPath = path.join(__dirname, `../../../${e2eLogName}`);
1515

16+
// Each test opens a document (2s sleep) and waits up to 30s for the webview to be ready.
17+
jest.setTimeout(60000);
18+
1619
describe("deploypane", (): void => {
1720
afterEach(executeCloseAllEditors);
1821

src/vscode-bicep/src/test/e2e/testReporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ export default class TestReporter implements Pick<Reporter, "onTestResult" | "on
3131
onRunComplete(_contexts: Set<TestContext>, results: AggregatedResult): void {
3232
console.log("");
3333
console.log(`Test Suites: ${results.numPassedTestSuites} passed, ${results.numTotalTestSuites} total`);
34-
console.log(`Tests: ${results.numPassedTestSuites} passed, ${results.numTotalTestSuites} total`);
34+
console.log(`Tests: ${results.numPassedTests} passed, ${results.numTotalTests} total`);
3535
}
3636
}

src/vscode-bicep/src/test/e2e/visualizer.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { resolveExamplePath } from "./examples";
1818

1919
const extensionLogPath = path.join(__dirname, `../../../${e2eLogName}`);
2020

21+
// Each test opens a document (2s sleep) and waits up to 20s for the visualizer to be ready.
22+
jest.setTimeout(30000);
23+
2124
describe("visualizer", (): void => {
2225
afterEach(executeCloseAllEditors);
2326

@@ -32,6 +35,7 @@ describe("visualizer", (): void => {
3235
const viewColumn = await executeShowVisualizerCommand(document.uri);
3336
await until(() => visualizerIsReady(document.uri), {
3437
interval: 100,
38+
timeoutMs: 20000,
3539
});
3640
if (!visualizerIsReady(document.uri)) {
3741
throw new Error(`Expected visualizer to be ready for ${document.uri.toString()}`);
@@ -50,6 +54,7 @@ describe("visualizer", (): void => {
5054
const viewColumn = await executeShowVisualizerToSideCommand(document.uri);
5155
await until(() => visualizerIsReady(document.uri), {
5256
interval: 100,
57+
timeoutMs: 20000,
5358
});
5459
if (!visualizerIsReady(document.uri)) {
5560
throw new Error(`Expected visualizer to be ready for ${document.uri.toString()}`);
@@ -68,6 +73,7 @@ describe("visualizer", (): void => {
6873

6974
await until(() => visualizerIsReady(document.uri), {
7075
interval: 100,
76+
timeoutMs: 20000,
7177
});
7278

7379
if (!visualizerIsReady(document.uri)) {

src/vscode-bicep/src/test/utils/time.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export async function retryWhile<T>(
88
predicate: (result: T) => boolean,
99
retryOptions?: Readonly<{
1010
interval?: number;
11-
timeout?: number;
11+
timeoutMs?: number;
1212
}>,
1313
): Promise<T> {
1414
let result = await func();
1515

1616
const interval = retryOptions?.interval ?? 2000;
17-
let count = (retryOptions?.timeout ?? 10000) / interval;
17+
let count = (retryOptions?.timeoutMs ?? 10000) / interval;
1818

1919
while (predicate(result)) {
2020
if (count-- <= 0) {

0 commit comments

Comments
 (0)