Skip to content

Fix flaky test #4547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
".jsx"
],
"require": "source-map-support/register",
"timeout": 10000,
"timeout": 30000,
"slow": 2000,
"spec": "out/test/**/*.test.js"
}
1 change: 0 additions & 1 deletion test/core/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as vscode from "vscode";
import { Settings, getSettings, getEffectiveConfigurationTarget, changeSetting, CommentType } from "../../src/settings";

describe("Settings E2E", function () {
this.slow(800);
it("Loads without error", function () {
assert.doesNotThrow(getSettings);
});
Expand Down
1 change: 0 additions & 1 deletion test/features/CustomViews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function convertToVSCodeResourceScheme(filePath: string): string {
}

describe("CustomViews feature", function () {
this.slow(1500);
const testCases: IHtmlContentViewTestCase[] = [
{
name: "with no JavaScript or CSS",
Expand Down
43 changes: 18 additions & 25 deletions test/features/DebugSession.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,42 +429,35 @@ describe("DebugSessionFeature", () => {
});
});

describe("DebugSessionFeature E2E", function slowTests() {
this.slow(20 * 1000); // Will warn if test takes longer than 10s and show red if longer than 20s
this.timeout(5 * 60 * 1000); // Give it five minutes, some CI is slow!

describe("DebugSessionFeature E2E", () => {
before(async () => {
// Registers and warms up the debug adapter and the PowerShell Extension Terminal
await ensureEditorServicesIsConnected();
});

it("Starts and stops a debugging session", async () => {
// Inspect the debug session via the started events to ensure it is correct
let startDebugSession: DebugSession;
let stopDebugSession: DebugSession;
const interactiveSessionConfig = defaultDebugConfigurations[DebugConfig.InteractiveSession];
// Asserts don't seem to fire in this event or the event doesn't resolve
// in the test code flow, so we need to "extract" the values for later
// use by the asserts

const startDebugEvent = debug.onDidStartDebugSession((newDebugSession) => {
startDebugEvent.dispose();
startDebugSession = newDebugSession;
const stopDebugEvent = debug.onDidTerminateDebugSession((terminatedDebugSession) => {
stopDebugEvent.dispose();
stopDebugSession = terminatedDebugSession;
const startDebugSession = new Promise<DebugSession>((resolve) => {
const event = debug.onDidStartDebugSession((session) => {
resolve(session);
event.dispose();
});
});
const stopDebugSession = new Promise<DebugSession>((resolve) => {
const event = debug.onDidTerminateDebugSession((session) => {
resolve(session);
event.dispose();
});
});

const debugSessionStarted = await debug.startDebugging(undefined, interactiveSessionConfig);
assert.ok(debugSessionStarted, "Debug session should start");
assert.equal(startDebugSession!.name, interactiveSessionConfig.name, "Debug session name should match when started");
// debugSession var should be populated from the event before startDebugging completes
await debug.stopDebugging(startDebugSession!);
const config = defaultDebugConfigurations[DebugConfig.InteractiveSession];
assert.ok(await debug.startDebugging(undefined, config), "Debug session should start");
assert.equal((await startDebugSession).name, config.name, "Debug session name should match when started");

assert.equal(stopDebugSession!.name, interactiveSessionConfig.name, "Debug session name should match when stopped");
assert.equal(stopDebugSession!.configuration.internalConsoleOptions, "neverOpen", "Debug session should always have neverOpen internalConsoleOptions");
assert.ok(stopDebugSession!, "Debug session should stop");
await debug.stopDebugging(await startDebugSession);
assert.ok(await stopDebugSession, "Debug session should stop");
assert.equal((await stopDebugSession).name, config.name, "Debug session name should match when stopped");
assert.equal((await stopDebugSession).configuration.internalConsoleOptions, "neverOpen", "Debug session should always have neverOpen internalConsoleOptions");
});

describe("Binary Modules", () => {
Expand Down
1 change: 0 additions & 1 deletion test/features/ISECompatibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ describe("ISE compatibility feature", function () {
});

describe("Color theme interactions", function () {
this.slow(4000);
beforeEach(enableISEMode);

function assertISESettings(): void {
Expand Down
1 change: 0 additions & 1 deletion test/features/RunCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe("RunCode feature", function () {
});

it("Runs Pester tests from a file", async function () {
this.slow(5000);
const pesterTests = path.resolve(__dirname, "../../../examples/Tests/SampleModule.Tests.ps1");
assert(checkIfFileExists(pesterTests));
const pesterTestDebugStarted = utils.WaitEvent<vscode.DebugSession>(vscode.debug.onDidStartDebugSession,
Expand Down
1 change: 0 additions & 1 deletion test/features/UpdatePowerShell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ describe("UpdatePowerShell feature", function () {
});

describe("Which version it gets", function () {
this.slow(2000);
it("Would update to LTS", async function() {
process.env.POWERSHELL_UPDATECHECK = "LTS";
const version: IPowerShellVersionDetails = {
Expand Down