@@ -6,9 +6,9 @@ import * as fs from "fs";
6
6
import * as path from "path" ;
7
7
import rewire = require( "rewire" ) ;
8
8
import vscode = require( "vscode" ) ;
9
+ import { suiteSetup } from "mocha" ;
9
10
import utils = require( "../utils" ) ;
10
11
import { sleep } from "../../src/utils" ;
11
- import { IPowerShellExtensionClient } from "../../src/features/ExternalApi" ;
12
12
13
13
// Setup function that is not exported.
14
14
const customViews = rewire ( "../../src/features/RunCode" ) ;
@@ -20,6 +20,8 @@ enum LaunchType {
20
20
}
21
21
22
22
suite ( "RunCode tests" , ( ) => {
23
+ suiteSetup ( utils . ensureExtensionIsActivated ) ;
24
+
23
25
test ( "Can create the launch config" , ( ) => {
24
26
const commandToRun : string = "Invoke-Build" ;
25
27
const args : string [ ] = [ "Clean" ] ;
@@ -41,33 +43,20 @@ suite("RunCode tests", () => {
41
43
assert . deepStrictEqual ( actual , expected ) ;
42
44
} ) ;
43
45
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 ( ) => {
50
47
const pesterTests = path . resolve ( __dirname , "../../../examples/Tests/SampleModule.Tests.ps1" ) ;
51
48
assert ( fs . existsSync ( pesterTests ) ) ;
52
49
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.
62
52
await vscode . commands . executeCommand ( "vscode.open" , vscode . Uri . file ( pesterTests ) ) ;
63
- await client . getPowerShellVersionDetails ( sessionId ) ;
64
- client . unregisterExternalExtension ( sessionId ) ;
53
+ await sleep ( 10000 ) ;
65
54
66
55
// Now run the Pester tests, check the debugger started, wait a bit for
67
56
// it to run, and then kill it for safety's sake.
68
57
assert ( await vscode . commands . executeCommand ( "PowerShell.RunPesterTestsFromFile" ) ) ;
69
58
assert ( vscode . debug . activeDebugSession !== undefined ) ;
70
59
await sleep ( 5000 ) ;
71
60
await vscode . debug . stopDebugging ( ) ;
72
- } ) ;
61
+ } ) . timeout ( 30000 ) ;
73
62
} ) ;
0 commit comments