@@ -38,8 +38,8 @@ export class PesterTestsFeature implements IFeature {
3838 // This command is provided for usage by PowerShellEditorServices (PSES) only
3939 this . command = vscode . commands . registerCommand (
4040 "PowerShell.RunPesterTests" ,
41- ( uriString , runInDebugger , describeBlockName ?, describeBlockLineNumber ?) => {
42- this . launchTests ( uriString , runInDebugger , describeBlockName , describeBlockLineNumber ) ;
41+ ( uriString , runInDebugger , describeBlockName ?, describeBlockLineNumber ?, outputPath ? ) => {
42+ this . launchTests ( uriString , runInDebugger , describeBlockName , describeBlockLineNumber , outputPath ) ;
4343 } ) ;
4444 }
4545
@@ -52,24 +52,30 @@ export class PesterTestsFeature implements IFeature {
5252 }
5353
5454 private launchAllTestsInActiveEditor ( launchType : LaunchType , fileUri : vscode . Uri ) {
55- const uriString = fileUri . toString ( ) ;
55+ const uriString = ( fileUri || vscode . window . activeTextEditor . document . uri ) . toString ( ) ;
5656 const launchConfig = this . createLaunchConfig ( uriString , launchType ) ;
57- launchConfig . args . push ( "-All" ) ;
5857 this . launch ( launchConfig ) ;
5958 }
6059
6160 private async launchTests (
6261 uriString : string ,
6362 runInDebugger : boolean ,
6463 describeBlockName ?: string ,
65- describeBlockLineNumber ?: number ) {
64+ describeBlockLineNumber ?: number ,
65+ outputPath ?: string ) {
6666
6767 const launchType = runInDebugger ? LaunchType . Debug : LaunchType . Run ;
68- const launchConfig = this . createLaunchConfig ( uriString , launchType , describeBlockName , describeBlockLineNumber ) ;
68+ const launchConfig = this . createLaunchConfig ( uriString , launchType , describeBlockName , describeBlockLineNumber , outputPath ) ;
6969 this . launch ( launchConfig ) ;
7070 }
7171
72- private createLaunchConfig ( uriString : string , launchType : LaunchType , testName ?: string , lineNum ?: number ) {
72+ private createLaunchConfig (
73+ uriString : string ,
74+ launchType : LaunchType ,
75+ testName ?: string ,
76+ lineNum ?: number ,
77+ outputPath ?: string ) {
78+
7379 const uri = vscode . Uri . parse ( uriString ) ;
7480 const currentDocument = vscode . window . activeTextEditor . document ;
7581 const settings = Settings . load ( ) ;
@@ -98,15 +104,15 @@ export class PesterTestsFeature implements IFeature {
98104
99105 if ( lineNum ) {
100106 launchConfig . args . push ( "-LineNumber" , `${ lineNum } ` ) ;
101- }
102-
103- if ( testName ) {
107+ } else if ( testName ) {
104108 // Escape single quotes inside double quotes by doubling them up
105109 if ( testName . includes ( "'" ) ) {
106110 testName = testName . replace ( / ' / g, "''" ) ;
107111 }
108112
109113 launchConfig . args . push ( "-TestName" , `'${ testName } '` ) ;
114+ } else {
115+ launchConfig . args . push ( "-All" ) ;
110116 }
111117
112118 if ( ! settings . pester . useLegacyCodeLens ) {
@@ -120,6 +126,10 @@ export class PesterTestsFeature implements IFeature {
120126 launchConfig . args . push ( "-Output" , `'${ settings . pester . outputVerbosity } '` ) ;
121127 }
122128
129+ if ( outputPath ) {
130+ launchConfig . args . push ( "-OutputPath" , `'${ outputPath } '` ) ;
131+ }
132+
123133 return launchConfig ;
124134 }
125135
0 commit comments