Skip to content

Commit

Permalink
Stabilize vscode e2e tests second trail (Azure#721)
Browse files Browse the repository at this point in the history
* Open a bicep file to warm up language server

* Should sleep in each individual tests
  • Loading branch information
shenglol authored Oct 23, 2020
1 parent c8152ae commit 60a4497
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/vscode-bicep/src/test/e2e/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Position } from "vscode";
import { readExampleFile } from "./examples";
import { executeCompletionItemProviderCommand } from "./commands";
import { expectDefined } from "../utils/assert";
import { sleep } from "../utils/time";

describe("completion", (): void => {
let document: vscode.TextDocument;
Expand All @@ -20,6 +21,10 @@ describe("completion", (): void => {
});

editor = await vscode.window.showTextDocument(document);

// Give the language server sometime to finish compilation. If this is the first test
// to run it may take long for the compilation to complete because JIT is not "warmed up".
await sleep(2000);
});

afterAll(async () => {
Expand Down
6 changes: 0 additions & 6 deletions src/vscode-bicep/src/test/e2e/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import NodeEnvironment = require("jest-environment-node");
import * as vscode from "vscode";

function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

class VSCodeEnvironment extends NodeEnvironment {
async setup(): Promise<void> {
await super.setup();
Expand All @@ -22,8 +18,6 @@ class VSCodeEnvironment extends NodeEnvironment {
await bicepExtension.activate();
}

await sleep(2000);

this.global.vscode = vscode;
}

Expand Down
5 changes: 5 additions & 0 deletions src/vscode-bicep/src/test/e2e/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as vscode from "vscode";

import { expectDefined, expectRange } from "../utils/assert";
import { sleep } from "../utils/time";
import { executeHoverProviderCommand } from "./commands";
import { readExampleFile } from "./examples";

Expand All @@ -17,6 +18,10 @@ describe("hover", (): void => {
});

await vscode.window.showTextDocument(document);

// Give the language server sometime to finish compilation. If this is the first test
// to run it may take long for the compilation to complete because JIT is not "warmed up".
await sleep(2000);
});

afterAll(async () => {
Expand Down
5 changes: 5 additions & 0 deletions src/vscode-bicep/src/test/utils/time.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

0 comments on commit 60a4497

Please sign in to comment.