File tree Expand file tree Collapse file tree 6 files changed +128
-17
lines changed Expand file tree Collapse file tree 6 files changed +128
-17
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,8 @@ export class EvaluationTestDiscoverer implements ITestDiscoverer {
9898 sourceMap ?: TraceMap | undefined ,
9999 directive ?: string ,
100100 ) {
101- const fn = ( name : string , callback : ( ) => void ) => {
102- if ( typeof name !== 'string' || typeof callback !== 'function' ) {
101+ const fn = ( name : string , callback : ( ( ) => void ) | undefined ) => {
102+ if ( typeof name !== 'string' ) {
103103 return placeholder ( ) ;
104104 }
105105
@@ -114,7 +114,7 @@ export class EvaluationTestDiscoverer implements ITestDiscoverer {
114114 let startColumn = frame . columnNumber || 1 ;
115115
116116 // approximate the length of the test case:
117- const functionLines = String ( callback ) . split ( '\n' ) ;
117+ const functionLines = String ( callback ?? '' ) . split ( '\n' ) ;
118118 let endLine = startLine + functionLines . length - 1 ;
119119 let endColumn = functionLines [ functionLines . length - 1 ] . length + 1 ;
120120
@@ -167,7 +167,7 @@ export class EvaluationTestDiscoverer implements ITestDiscoverer {
167167 if ( kind === NodeKind . Suite ) {
168168 stack . push ( node ) ;
169169 try {
170- return callback . call ( placeholder ( ) ) ;
170+ return typeof callback === 'function' ? callback . call ( placeholder ( ) ) : placeholder ( ) ;
171171 } catch ( e ) {
172172 node . error = e instanceof Error ? e . message : String ( e ) ;
173173 } finally {
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export class SyntaxTestDiscoverer implements ITestDiscoverer {
104104
105105 traverse ( ast , {
106106 enter ( node ) {
107- if ( node . type !== C . CallExpression || node . arguments . length < 2 ) {
107+ if ( node . type !== C . CallExpression || node . arguments . length === 0 ) {
108108 return ;
109109 }
110110
Original file line number Diff line number Diff line change @@ -237,18 +237,8 @@ export class TestRunner {
237237 }
238238
239239 if ( ! spawnCts . token . isCancellationRequested ) {
240- if ( ranAnyTest ) {
241- for ( const t of leafTests ) {
242- run . skipped ( t ) ;
243- }
244- } else {
245- const md = new vscode . MarkdownString (
246- 'Test process exited unexpectedly, [view output](command:testing.showMostRecentOutput)' ,
247- ) ;
248- md . isTrusted = true ;
249- for ( const t of leafTests ) {
250- run . errored ( t , new vscode . TestMessage ( md ) ) ;
251- }
240+ for ( const t of leafTests ) {
241+ run . skipped ( t ) ;
252242 }
253243 }
254244
Original file line number Diff line number Diff line change @@ -197,4 +197,37 @@ describe('evaluate typescript', () => {
197197 } ,
198198 ] ) ;
199199 } ) ;
200+
201+ it ( 'works with pending test' , async ( ) => {
202+ const src = await extractWithEvaluation (
203+ 'function topLevel(a: number): string {' , //
204+ ' return a.toString() as string;' ,
205+ '}' ,
206+ '' ,
207+ "suite('hello', () => {" , //
208+ " it('works');" ,
209+ '})' ,
210+ ) ;
211+ expect ( src ) . to . deep . equal ( [
212+ {
213+ name : 'hello' ,
214+ kind : NodeKind . Suite ,
215+ startLine : 4 ,
216+ startColumn : 0 ,
217+ endColumn : 1 ,
218+ endLine : 6 ,
219+ children : [
220+ {
221+ name : 'works' ,
222+ kind : NodeKind . Test ,
223+ startLine : 5 ,
224+ startColumn : 2 ,
225+ endColumn : Number . MAX_SAFE_INTEGER ,
226+ endLine : 5 ,
227+ children : [ ] ,
228+ } ,
229+ ] ,
230+ } ,
231+ ] ) ;
232+ } ) ;
200233} ) ;
Original file line number Diff line number Diff line change @@ -162,6 +162,50 @@ describe('evaluate', () => {
162162 ] ) ;
163163 } ) ;
164164
165+ it ( 'works with pending test' , async ( ) => {
166+ const src = await extractWithEvaluation (
167+ "suite('hello', () => {" , //
168+ " it('works');" ,
169+ '})' ,
170+ ) ;
171+ expect ( src ) . to . deep . equal ( [
172+ {
173+ name : 'hello' ,
174+ startLine : 0 ,
175+ kind : NodeKind . Suite ,
176+ startColumn : 0 ,
177+ endColumn : 1 ,
178+ endLine : 2 ,
179+ children : [
180+ {
181+ name : 'works' ,
182+ kind : NodeKind . Test ,
183+ startLine : 1 ,
184+ startColumn : 2 ,
185+ endColumn : Number . MAX_SAFE_INTEGER ,
186+ endLine : 1 ,
187+ children : [ ] ,
188+ } ,
189+ ] ,
190+ } ,
191+ ] ) ;
192+ } ) ;
193+
194+ it ( 'works with pending suite' , async ( ) => {
195+ const src = await extractWithEvaluation ( "suite('hello')" ) ;
196+ expect ( src ) . to . deep . equal ( [
197+ {
198+ name : 'hello' ,
199+ startLine : 0 ,
200+ kind : NodeKind . Suite ,
201+ startColumn : 0 ,
202+ endColumn : Number . MAX_SAFE_INTEGER ,
203+ endLine : 0 ,
204+ children : [ ] ,
205+ } ,
206+ ] ) ;
207+ } ) ;
208+
165209 it ( 'stubs out requires and placeholds correctly' , async ( ) => {
166210 const src = await extractWithEvaluation (
167211 'require("some invalid module").doing().other.things()' ,
Original file line number Diff line number Diff line change @@ -94,6 +94,50 @@ describe('syntax', () => {
9494 ] ) ;
9595 } ) ;
9696
97+ it ( 'works with pending test' , async ( ) => {
98+ const src = await extractWithAst (
99+ "suite('hello', () => {" , //
100+ " it('works');" ,
101+ '})' ,
102+ ) ;
103+ expect ( src ) . to . deep . equal ( [
104+ {
105+ name : 'hello' ,
106+ startLine : 0 ,
107+ kind : NodeKind . Suite ,
108+ startColumn : 0 ,
109+ endColumn : 2 ,
110+ endLine : 2 ,
111+ children : [
112+ {
113+ name : 'works' ,
114+ kind : NodeKind . Test ,
115+ startLine : 1 ,
116+ startColumn : 2 ,
117+ endColumn : 13 ,
118+ endLine : 1 ,
119+ children : [ ] ,
120+ } ,
121+ ] ,
122+ } ,
123+ ] ) ;
124+ } ) ;
125+
126+ it ( 'works with pending suite' , async ( ) => {
127+ const src = await extractWithAst ( "suite('hello')" ) ;
128+ expect ( src ) . to . deep . equal ( [
129+ {
130+ name : 'hello' ,
131+ startLine : 0 ,
132+ kind : NodeKind . Suite ,
133+ startColumn : 0 ,
134+ endColumn : 14 ,
135+ endLine : 0 ,
136+ children : [ ] ,
137+ } ,
138+ ] ) ;
139+ } ) ;
140+
97141 it ( 'can detect suite but not dynamic tests' , async ( ) => {
98142 const src = await extractWithAst (
99143 "suite('hello', () => {" , //
You can’t perform that action at this time.
0 commit comments