@@ -13,6 +13,7 @@ import { test } from '@japa/runner'
13
13
import { join , sep } from 'node:path'
14
14
import { cliui } from '@poppinss/cliui'
15
15
import { setTimeout as sleep } from 'node:timers/promises'
16
+ import { RuntimeException } from '@poppinss/utils/exception'
16
17
17
18
import { DevServer } from '../index.ts'
18
19
@@ -322,4 +323,52 @@ test.group('DevServer', () => {
322
323
0
323
324
)
324
325
} ) . disableTimeout ( )
326
+
327
+ test ( 'return error when tsconfig file is missing' , async ( { fs, assert, cleanup } ) => {
328
+ let hooksStack : string [ ] = [ ]
329
+ let error : any
330
+
331
+ await fs . create (
332
+ 'bin/server.ts' ,
333
+ `process.send({ isAdonisJS: true, environment: 'web', port: process.env.PORT, host: 'localhost' })`
334
+ )
335
+ await fs . create ( '.env' , 'PORT=3335' )
336
+
337
+ const devServer = new DevServer ( fs . baseUrl , {
338
+ nodeArgs : [ ] ,
339
+ scriptArgs : [ ] ,
340
+ metaFiles : [ ] ,
341
+ suites : [ ] ,
342
+ hooks : {
343
+ devServerStarted : [
344
+ async ( ) => ( {
345
+ default : ( ) => {
346
+ hooksStack . push ( 'devServerStarted' )
347
+ } ,
348
+ } ) ,
349
+ ] ,
350
+ devServerStarting : [
351
+ async ( ) => ( {
352
+ default : ( ) => {
353
+ hooksStack . push ( 'devServerStarting' )
354
+ } ,
355
+ } ) ,
356
+ ] ,
357
+ } ,
358
+ } )
359
+
360
+ devServer . ui = cliui ( )
361
+ devServer . ui . switchMode ( 'raw' )
362
+
363
+ devServer . onError ( ( startError ) => {
364
+ error = startError
365
+ } )
366
+
367
+ await devServer . startAndWatch ( ts )
368
+ cleanup ( ( ) => devServer . close ( ) )
369
+
370
+ assert . instanceOf ( error , RuntimeException )
371
+ assert . deepEqual ( devServer . ui . logger . getLogs ( ) , [ ] )
372
+ assert . deepEqual ( hooksStack , [ ] )
373
+ } )
325
374
} )
0 commit comments