@@ -6,9 +6,9 @@ import * as fs from "fs";
66import * as path from "path" ;
77import rewire = require( "rewire" ) ;
88import vscode = require( "vscode" ) ;
9+ import { suiteSetup } from "mocha" ;
910import utils = require( "../utils" ) ;
1011import { sleep } from "../../src/utils" ;
11- import { IPowerShellExtensionClient } from "../../src/features/ExternalApi" ;
1212
1313// Setup function that is not exported.
1414const customViews = rewire ( "../../src/features/RunCode" ) ;
@@ -20,6 +20,8 @@ enum LaunchType {
2020}
2121
2222suite ( "RunCode tests" , ( ) => {
23+ suiteSetup ( utils . ensureExtensionIsActivated ) ;
24+
2325 test ( "Can create the launch config" , ( ) => {
2426 const commandToRun : string = "Invoke-Build" ;
2527 const args : string [ ] = [ "Clean" ] ;
@@ -41,33 +43,20 @@ suite("RunCode tests", () => {
4143 assert . deepStrictEqual ( actual , expected ) ;
4244 } ) ;
4345
44- test ( "Can run Pester tests from file" , async function ( ) {
45- // PowerShell can take a while and is flaky, so try three times and set
46- // the timeout to thirty seconds each.
47- this . retries ( 3 ) ;
48- this . timeout ( 30000 ) ;
49-
46+ test ( "Can run Pester tests from file" , async ( ) => {
5047 const pesterTests = path . resolve ( __dirname , "../../../examples/Tests/SampleModule.Tests.ps1" ) ;
5148 assert ( fs . existsSync ( pesterTests ) ) ;
5249
53- // Get interface to extension.
54- const extension = await utils . ensureExtensionIsActivated ( ) ;
55- const client = extension ! . exports as IPowerShellExtensionClient ;
56- const sessionId = client . registerExternalExtension ( utils . extensionId ) ;
57-
58- // Force PowerShell extension to finish connecting. This is necessary
59- // because we can't start the PowerShell debugger until the session is
60- // connected, which is different from the extension being activated. We
61- // also need to open the file so the command has it as its argument.
50+ // Open the PowerShell file with Pester tests and then wait a while for
51+ // the extension to finish connecting to the server.
6252 await vscode . commands . executeCommand ( "vscode.open" , vscode . Uri . file ( pesterTests ) ) ;
63- await client . getPowerShellVersionDetails ( sessionId ) ;
64- client . unregisterExternalExtension ( sessionId ) ;
53+ await sleep ( 15000 ) ;
6554
6655 // Now run the Pester tests, check the debugger started, wait a bit for
6756 // it to run, and then kill it for safety's sake.
6857 assert ( await vscode . commands . executeCommand ( "PowerShell.RunPesterTestsFromFile" ) ) ;
6958 assert ( vscode . debug . activeDebugSession !== undefined ) ;
7059 await sleep ( 5000 ) ;
7160 await vscode . debug . stopDebugging ( ) ;
72- } ) ;
61+ } ) . timeout ( 30000 ) ;
7362} ) ;
0 commit comments