@@ -33,7 +33,7 @@ import type {
3333import type { Class } from 'type-fest' ;
3434
3535const parseErrorStackRegExp =
36- / a t (?< fn > \S + ) (?: .* ? ) ? \( ? (?< path > (?: \/ | f i l e : | \w : \\ ) .* ?) (?: \) | $ ) / i;
36+ / a t (?: (? <fn > \S + ) ) ? (?: .* ? ) ? \( ? (?< path > (?: \/ | f i l e : | \w : \\ ) .* ?) (?: \) | $ ) / i;
3737
3838const parseScriptFilepathRegExp =
3939 / ( \/ | \\ ) b a b e l - p l u g i n - t e s t e r ( \/ | \\ ) ( d i s t | s r c ) ( \/ | \\ ) ( i n d e x | p l u g i n - t e s t e r ) \. ( j | t ) s $ / ;
@@ -118,8 +118,8 @@ function pluginTester(options: PluginTesterOptions = {}) {
118118 const globalContextExpectFnHasToMatchSnapshot = ( ( ) => {
119119 try {
120120 return globalContextHasExpectFn
121- ? typeof expect ( undefined ) ?. toMatchSnapshot == 'function'
122- : false ;
121+ ? typeof expect ( undefined ) ?. toMatchSnapshot == 'function'
122+ : false ;
123123 } catch {
124124 /* istanbul ignore next */
125125 return false ;
@@ -328,7 +328,7 @@ function pluginTester(options: PluginTesterOptions = {}) {
328328 process . cwd ( )
329329 ) ;
330330
331- debug2 ( 'plugin name inference succeeded : %O' , name ) ;
331+ debug2 ( 'plugin name inference result : %O' , name ) ;
332332 return name ;
333333 } catch {
334334 debug2 ( 'plugin name inference failed' ) ;
@@ -358,11 +358,16 @@ function pluginTester(options: PluginTesterOptions = {}) {
358358 const { fn : functionName , path : filePath } =
359359 line . match ( parseErrorStackRegExp ) ?. groups || { } ;
360360
361- return functionName && filePath
361+ return filePath
362362 ? {
363363 functionName,
364364 // ? Paranoid just in case the script name/path has colons
365- filePath : filePath . split ( ':' ) . slice ( 0 , - 2 ) . join ( ':' )
365+ filePath : filePath
366+ . split ( 'file://' )
367+ . at ( - 1 ) !
368+ . split ( ':' )
369+ . slice ( 0 , - 2 )
370+ . join ( ':' )
366371 }
367372 : undefined ;
368373 } )
0 commit comments