@@ -12,7 +12,6 @@ import { mockCheckForUpdates } from '../utils/mockCheckForUpdates';
12
12
import { mockLogger } from '../utils/mockLogger' ;
13
13
import { resetDiskAndMocks } from '../utils/resetDiskAndMocks' ;
14
14
import { runInit , runDev , bootstrapProject , resetConfigAndMocks } from '../utils/runCommands' ;
15
- import { runInitTemp } from '../utils/testHelpers' ;
16
15
17
16
vi . mock ( 'chokidar' , async ( ) => {
18
17
const mod = await vi . importActual ( 'chokidar' ) ;
@@ -85,24 +84,38 @@ describe('dev', () => {
85
84
} ) ;
86
85
87
86
it ( 'exits when build fails' , { timeout : 30_000 } , async ( ) => {
88
- using temp = runInitTemp ( ) ;
89
- const mainSw = readFileSync ( `${ temp . contractDir } /src/main.sw` ) . toString ( ) ;
87
+ const mainSw = readFileSync ( `${ paths . contractsBarDir } /src/main.sw` ) . toString ( ) ;
90
88
const invalidSwayCode = `${ mainSw } \nabi ` ;
91
- writeFileSync ( `${ temp . contractDir } /src/main.sw` , invalidSwayCode ) ;
89
+ writeFileSync ( `${ paths . contractsBarDir } /src/main.sw` , invalidSwayCode ) ;
92
90
93
- const devProcess = spawn ( 'pnpm fuels dev' , {
94
- cwd : temp . rootDir ,
91
+ await runInit ( {
92
+ root : paths . root ,
93
+ output : paths . outputDir ,
94
+ workspace : paths . workspaceDir ,
95
+ fuelCorePort : '0' ,
96
+ } ) ;
97
+
98
+ const devProcess = spawn ( `pnpm fuels dev --path ${ paths . root } ` , {
95
99
detached : true ,
96
100
shell : 'bash' ,
97
101
} ) ;
98
102
103
+ const data : string [ ] = [ ] ;
104
+
105
+ devProcess . stdout ?. on ( 'data' , ( chunk ) => {
106
+ data . push ( chunk . toString ( ) ) ;
107
+ } ) ;
108
+
99
109
await new Promise ( ( resolve ) => {
100
110
devProcess . on ( 'exit' , ( code ) => {
101
111
expect ( code ) . not . toEqual ( 0 ) ;
102
112
resolve ( undefined ) ;
103
113
} ) ;
104
114
} ) ;
115
+
116
+ expect ( data . join ( '' ) ) . toContain ( 'forc exited with error code 1' ) ;
105
117
} ) ;
118
+
106
119
test ( '`dev` command can work with ephemeral port 0' , { timeout : 25000 } , async ( ) => {
107
120
await runInit ( {
108
121
root : paths . root ,
0 commit comments