Skip to content

Commit 14961fa

Browse files
Merge pull request #4547 from PowerShell/andschwa/flaky-test
Fix flaky test
2 parents d367a8d + 002fbdc commit 14961fa

7 files changed

+20
-31
lines changed

.mocharc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
".jsx"
77
],
88
"require": "source-map-support/register",
9-
"timeout": 10000,
9+
"timeout": 30000,
10+
"slow": 2000,
1011
"spec": "out/test/**/*.test.js"
1112
}

test/core/settings.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as vscode from "vscode";
66
import { Settings, getSettings, getEffectiveConfigurationTarget, changeSetting, CommentType } from "../../src/settings";
77

88
describe("Settings E2E", function () {
9-
this.slow(800);
109
it("Loads without error", function () {
1110
assert.doesNotThrow(getSettings);
1211
});

test/features/CustomViews.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ function convertToVSCodeResourceScheme(filePath: string): string {
3030
}
3131

3232
describe("CustomViews feature", function () {
33-
this.slow(1500);
3433
const testCases: IHtmlContentViewTestCase[] = [
3534
{
3635
name: "with no JavaScript or CSS",

test/features/DebugSession.test.ts

+18-25
Original file line numberDiff line numberDiff line change
@@ -429,42 +429,35 @@ describe("DebugSessionFeature", () => {
429429
});
430430
});
431431

432-
describe("DebugSessionFeature E2E", function slowTests() {
433-
this.slow(20 * 1000); // Will warn if test takes longer than 10s and show red if longer than 20s
434-
this.timeout(5 * 60 * 1000); // Give it five minutes, some CI is slow!
435-
432+
describe("DebugSessionFeature E2E", () => {
436433
before(async () => {
437434
// Registers and warms up the debug adapter and the PowerShell Extension Terminal
438435
await ensureEditorServicesIsConnected();
439436
});
440437

441438
it("Starts and stops a debugging session", async () => {
442439
// Inspect the debug session via the started events to ensure it is correct
443-
let startDebugSession: DebugSession;
444-
let stopDebugSession: DebugSession;
445-
const interactiveSessionConfig = defaultDebugConfigurations[DebugConfig.InteractiveSession];
446-
// Asserts don't seem to fire in this event or the event doesn't resolve
447-
// in the test code flow, so we need to "extract" the values for later
448-
// use by the asserts
449-
450-
const startDebugEvent = debug.onDidStartDebugSession((newDebugSession) => {
451-
startDebugEvent.dispose();
452-
startDebugSession = newDebugSession;
453-
const stopDebugEvent = debug.onDidTerminateDebugSession((terminatedDebugSession) => {
454-
stopDebugEvent.dispose();
455-
stopDebugSession = terminatedDebugSession;
440+
const startDebugSession = new Promise<DebugSession>((resolve) => {
441+
const event = debug.onDidStartDebugSession((session) => {
442+
resolve(session);
443+
event.dispose();
444+
});
445+
});
446+
const stopDebugSession = new Promise<DebugSession>((resolve) => {
447+
const event = debug.onDidTerminateDebugSession((session) => {
448+
resolve(session);
449+
event.dispose();
456450
});
457451
});
458452

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

465-
assert.equal(stopDebugSession!.name, interactiveSessionConfig.name, "Debug session name should match when stopped");
466-
assert.equal(stopDebugSession!.configuration.internalConsoleOptions, "neverOpen", "Debug session should always have neverOpen internalConsoleOptions");
467-
assert.ok(stopDebugSession!, "Debug session should stop");
457+
await debug.stopDebugging(await startDebugSession);
458+
assert.ok(await stopDebugSession, "Debug session should stop");
459+
assert.equal((await stopDebugSession).name, config.name, "Debug session name should match when stopped");
460+
assert.equal((await stopDebugSession).configuration.internalConsoleOptions, "neverOpen", "Debug session should always have neverOpen internalConsoleOptions");
468461
});
469462

470463
describe("Binary Modules", () => {

test/features/ISECompatibility.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ describe("ISE compatibility feature", function () {
7373
});
7474

7575
describe("Color theme interactions", function () {
76-
this.slow(4000);
7776
beforeEach(enableISEMode);
7877

7978
function assertISESettings(): void {

test/features/RunCode.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ describe("RunCode feature", function () {
4040
});
4141

4242
it("Runs Pester tests from a file", async function () {
43-
this.slow(5000);
4443
const pesterTests = path.resolve(__dirname, "../../../examples/Tests/SampleModule.Tests.ps1");
4544
assert(checkIfFileExists(pesterTests));
4645
const pesterTestDebugStarted = utils.WaitEvent<vscode.DebugSession>(vscode.debug.onDidStartDebugSession,

test/features/UpdatePowerShell.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ describe("UpdatePowerShell feature", function () {
107107
});
108108

109109
describe("Which version it gets", function () {
110-
this.slow(2000);
111110
it("Would update to LTS", async function() {
112111
process.env.POWERSHELL_UPDATECHECK = "LTS";
113112
const version: IPowerShellVersionDetails = {

0 commit comments

Comments
 (0)