11import { describe , test , expect , jest } from '@jest/globals' ;
22import { exec } from 'node:child_process' ;
33import { YError } from 'yerror' ;
4+ import { join as joinPaths } from 'node:path' ;
45
56jest . setTimeout ( 30000 ) ;
67
@@ -11,11 +12,11 @@ describe('commands should work', () => {
1112 ) ;
1213
1314 expect ( {
14- stdout : stdout . replace ( / ( | " | ' ) ( [ ^ ] + ) \/ w h o o k \/ / g , ' /whook/' ) ,
15- stderr : stderr . replace ( / ( | " | ' ) ( [ ^ ] + ) \/ w h o o k \/ / g , ' /whook/' ) ,
15+ stdout : replacePaths ( stdout ) ,
16+ stderr : replacePaths ( stderr ) ,
1617 } ) . toMatchInlineSnapshot ( `
1718{
18- "stderr": "⚡ - Loading configurations from /whook/packages/whook-example /dist/config/local/config.js".
19+ "stderr": "⚡ - Loading configurations from "file:///project /dist/config/local/config.js".
1920🤖 - Initializing the \`$autoload\` service.
2021🔴 - Running with "local" application environment.
2122🔂 - Running with "test" node environment.
@@ -56,11 +57,11 @@ On air 🚀🌕
5657 ) ;
5758
5859 expect ( {
59- stdout : stdout . replace ( / ( | " | ' ) ( [ ^ ] + ) \/ w h o o k \/ / g , ' /whook/' ) ,
60- stderr : stderr . replace ( / ( | " | ' ) ( [ ^ ] + ) \/ w h o o k \/ / g , ' /whook/' ) ,
60+ stdout : replacePaths ( stdout ) ,
61+ stderr : replacePaths ( stderr ) ,
6162 } ) . toMatchInlineSnapshot ( `
6263{
63- "stderr": "⚡ - Loading configurations from /whook/packages/whook-example /dist/config/local/config.js".
64+ "stderr": "⚡ - Loading configurations from "file:///project /dist/config/local/config.js".
6465🤖 - Initializing the \`$autoload\` service.
6566🔴 - Running with "local" application environment.
6667🔂 - Running with "test" node environment.
@@ -80,11 +81,11 @@ On air 🚀🌕
8081 ) ;
8182
8283 expect ( {
83- stdout : stdout . replace ( / ( | " | ' ) ( [ ^ ] + ) \/ w h o o k \/ / g , ' /whook/' ) ,
84- stderr : stderr . replace ( / ( | " | ' ) ( [ ^ ] + ) \/ w h o o k \/ / g , ' /whook/' ) ,
84+ stdout : replacePaths ( stdout ) ,
85+ stderr : replacePaths ( stderr ) ,
8586 } ) . toMatchInlineSnapshot ( `
8687{
87- "stderr": "⚡ - Loading configurations from /whook/packages/whook-example /dist/config/local/config.js".
88+ "stderr": "⚡ - Loading configurations from "file:///project /dist/config/local/config.js".
8889🤖 - Initializing the \`$autoload\` service.
8990🔴 - Running with "local" application environment.
9091🔂 - Running with "test" node environment.
@@ -112,3 +113,10 @@ async function execCommand(
112113 } ) ;
113114 } ) ;
114115}
116+
117+ function replacePaths ( text : string ) {
118+ return text . replaceAll (
119+ joinPaths ( import . meta. dirname , '..' ) . replace ( / ^ f i l e : \/ \/ / , '' ) ,
120+ '/project' ,
121+ ) ;
122+ }
0 commit comments