Skip to content

Commit 895b358

Browse files
committed
Fix Pester CodeLens not working for running/debugging tests
Fixes #1500
1 parent 6f576e4 commit 895b358

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/features/PesterTests.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import ChildProcess = require("child_process");
5+
import * as path from "path";
66
import vscode = require("vscode");
7-
import Window = vscode.window;
87
import { IFeature, LanguageClient } from "../feature";
98
import { SessionManager } from "../session";
109
import Settings = require("../settings");
@@ -40,22 +39,26 @@ export class PesterTestsFeature implements IFeature {
4039
request: "launch",
4140
type: "PowerShell",
4241
name: "PowerShell Launch Pester Tests",
43-
script: "Invoke-Pester",
42+
script: `Invoke-Pester`,
4443
args: [
45-
`-Script "${uri.fsPath}"`,
46-
describeBlockName
47-
? `-TestName '${describeBlockName}'`
48-
: "",
44+
"-Script",
45+
// Let PSES handle path quoting since it also handles escaping ' e.g. C:\temp\don't-use-this-path
46+
`${uri.fsPath}`,
4947
],
5048
internalConsoleOptions: "neverOpen",
5149
noDebug: !runInDebugger,
5250
createTemporaryIntegratedConsole: settings.debugging.createTemporaryIntegratedConsole,
5351
cwd:
5452
currentDocument.isUntitled
5553
? vscode.workspace.rootPath
56-
: currentDocument.fileName,
54+
: path.dirname(currentDocument.fileName),
5755
};
5856

57+
if (describeBlockName) {
58+
launchConfig.args.push("-TestName");
59+
launchConfig.args.push(`'${describeBlockName}'`);
60+
}
61+
5962
// Create or show the interactive console
6063
// TODO #367: Check if "newSession" mode is configured
6164
vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true);

0 commit comments

Comments
 (0)