@@ -4233,81 +4233,86 @@ describe.each([
42334233 } ) ;
42344234
42354235 describe ( "writeToDisk option" , ( ) => {
4236- describe ( 'should work with "true" value' , ( ) => {
4237- let compiler ;
4238-
4239- const outputPath = path . resolve (
4240- __dirname ,
4241- "./outputs/write-to-disk-true" ,
4242- ) ;
4236+ // TODO https://github.com/honojs/node-server/issues/233
4237+ ( name === "hono" ? describe . skip : describe ) (
4238+ 'should work with "true" value' ,
4239+ ( ) => {
4240+ let compiler ;
42434241
4244- beforeAll ( async ( ) => {
4245- compiler = getCompiler ( {
4246- ...webpackConfig ,
4247- output : {
4248- filename : "bundle.js" ,
4249- path : outputPath ,
4250- publicPath : "/public/" ,
4251- } ,
4252- } ) ;
4253-
4254- [ server , req , instance ] = await frameworkFactory (
4255- name ,
4256- framework ,
4257- compiler ,
4258- { writeToDisk : true } ,
4242+ const outputPath = path . resolve (
4243+ __dirname ,
4244+ "./outputs/write-to-disk-true" ,
42594245 ) ;
4260- } ) ;
4261-
4262- afterAll ( async ( ) => {
4263- await fs . promises . rm ( outputPath , {
4264- recursive : true ,
4265- force : true ,
4266- } ) ;
4267- await close ( server , instance ) ;
4268- } ) ;
42694246
4270- it ( "should find the bundle file on disk" , ( done ) => {
4271- req . get ( "/public/bundle.js" ) . expect ( 200 , ( error ) => {
4272- if ( error ) {
4273- return done ( error ) ;
4274- }
4247+ beforeAll ( async ( ) => {
4248+ compiler = getCompiler ( {
4249+ ...webpackConfig ,
4250+ output : {
4251+ filename : "bundle.js" ,
4252+ path : outputPath ,
4253+ publicPath : "/public/" ,
4254+ } ,
4255+ } ) ;
42754256
4276- const bundlePath = path . resolve (
4277- __dirname ,
4278- "./outputs/write-to-disk-true/bundle.js" ,
4257+ [ server , req , instance ] = await frameworkFactory (
4258+ name ,
4259+ framework ,
4260+ compiler ,
4261+ { writeToDisk : true } ,
42794262 ) ;
4263+ } ) ;
42804264
4281- expect (
4282- compiler . hooks . assetEmitted . taps . filter (
4283- ( hook ) => hook . name === "DevMiddleware" ,
4284- ) ,
4285- ) . toHaveLength ( 0 ) ;
4265+ afterAll ( async ( ) => {
4266+ await fs . promises . rm ( outputPath , {
4267+ recursive : true ,
4268+ force : true ,
4269+ } ) ;
4270+ await close ( server , instance ) ;
4271+ } ) ;
42864272
4287- expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4273+ it ( "should find the bundle file on disk" , ( done ) => {
4274+ req . get ( "/public/bundle.js" ) . expect ( 200 , ( error ) => {
4275+ if ( error ) {
4276+ return done ( error ) ;
4277+ }
4278+
4279+ const bundlePath = path . resolve (
4280+ __dirname ,
4281+ "./outputs/write-to-disk-true/bundle.js" ,
4282+ ) ;
42884283
4289- compiler . hooks . done . tap ( "DevMiddlewareWriteToDiskTest" , ( ) => {
42904284 expect (
42914285 compiler . hooks . assetEmitted . taps . filter (
42924286 ( hook ) => hook . name === "DevMiddleware" ,
42934287 ) ,
42944288 ) . toHaveLength ( 0 ) ;
4295- } ) ;
42964289
4297- instance . invalidate ( ( ) => {
4298- done ( ) ;
4290+ expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4291+
4292+ compiler . hooks . done . tap ( "DevMiddlewareWriteToDiskTest" , ( ) => {
4293+ expect (
4294+ compiler . hooks . assetEmitted . taps . filter (
4295+ ( hook ) => hook . name === "DevMiddleware" ,
4296+ ) ,
4297+ ) . toHaveLength ( 0 ) ;
4298+ } ) ;
4299+
4300+ instance . invalidate ( ( ) => {
4301+ done ( ) ;
4302+ } ) ;
42994303 } ) ;
43004304 } ) ;
4301- } ) ;
43024305
4303- it ( "should not allow to get files above root" , async ( ) => {
4304- const response = await req . get ( "/public/..%2f../middleware.test.js" ) ;
4306+ it ( "should not allow to get files above root" , async ( ) => {
4307+ const response = await req . get (
4308+ "/public/..%2f../middleware.test.js" ,
4309+ ) ;
43054310
4306- expect ( response . statusCode ) . toBe ( 403 ) ;
4307- expect ( response . headers [ "content-type" ] ) . toBe (
4308- "text/html; charset=utf-8" ,
4309- ) ;
4310- expect ( response . text ) . toBe ( `<!DOCTYPE html>
4311+ expect ( response . statusCode ) . toBe ( 403 ) ;
4312+ expect ( response . headers [ "content-type" ] ) . toBe (
4313+ "text/html; charset=utf-8" ,
4314+ ) ;
4315+ expect ( response . text ) . toBe ( `<!DOCTYPE html>
43114316<html lang="en">
43124317<head>
43134318<meta charset="utf-8">
@@ -4317,8 +4322,9 @@ describe.each([
43174322<pre>Forbidden</pre>
43184323</body>
43194324</html>` ) ;
4320- } ) ;
4321- } ) ;
4325+ } ) ;
4326+ } ,
4327+ ) ;
43224328
43234329 describe ( 'should work with "true" value when the `output.clean` is `true`' , ( ) => {
43244330 const outputPath = path . resolve (
@@ -4599,79 +4605,85 @@ describe.each([
45994605 } ) ;
46004606 } ) ;
46014607
4602- describe ( "should work in multi-compiler mode" , ( ) => {
4603- let compiler ;
4608+ // TODO https://github.com/honojs/node-server/issues/233
4609+ ( name === "hono" ? describe . skip : describe ) (
4610+ "should work in multi-compiler mode" ,
4611+ ( ) => {
4612+ let compiler ;
46044613
4605- const outputPath = path . resolve (
4606- __dirname ,
4607- "./outputs/write-to-disk-multi-compiler/" ,
4608- ) ;
4614+ const outputPath = path . resolve (
4615+ __dirname ,
4616+ "./outputs/write-to-disk-multi-compiler/" ,
4617+ ) ;
46094618
4610- beforeAll ( async ( ) => {
4611- compiler = getCompiler ( [
4612- {
4613- ...webpackMultiWatchOptionsConfig [ 0 ] ,
4614- output : {
4615- filename : "bundle.js" ,
4616- path : path . resolve (
4617- __dirname ,
4618- "./outputs/write-to-disk-multi-compiler/static-one" ,
4619- ) ,
4620- publicPath : "/static-one/" ,
4619+ // eslint-disable-next-line jest/no-duplicate-hooks
4620+ beforeAll ( async ( ) => {
4621+ compiler = getCompiler ( [
4622+ {
4623+ ...webpackMultiWatchOptionsConfig [ 0 ] ,
4624+ output : {
4625+ filename : "bundle.js" ,
4626+ path : path . resolve (
4627+ __dirname ,
4628+ "./outputs/write-to-disk-multi-compiler/static-one" ,
4629+ ) ,
4630+ publicPath : "/static-one/" ,
4631+ } ,
46214632 } ,
4622- } ,
4623- {
4624- ... webpackMultiWatchOptionsConfig [ 1 ] ,
4625- output : {
4626- filename : "bundle.js" ,
4627- path : path . resolve (
4628- __dirname ,
4629- "./outputs/write-to-disk-multi-compiler/static-two" ,
4630- ) ,
4631- publicPath : "/static-two/" ,
4633+ {
4634+ ... webpackMultiWatchOptionsConfig [ 1 ] ,
4635+ output : {
4636+ filename : "bundle.js" ,
4637+ path : path . resolve (
4638+ __dirname ,
4639+ "./outputs/write-to-disk-multi-compiler/static-two" ,
4640+ ) ,
4641+ publicPath : "/static-two/" ,
4642+ } ,
46324643 } ,
4633- } ,
4634- ] ) ;
4644+ ] ) ;
46354645
4636- [ server , req , instance ] = await frameworkFactory (
4637- name ,
4638- framework ,
4639- compiler ,
4640- { writeToDisk : true } ,
4641- ) ;
4642- } ) ;
4646+ [ server , req , instance ] = await frameworkFactory (
4647+ name ,
4648+ framework ,
4649+ compiler ,
4650+ { writeToDisk : true } ,
4651+ ) ;
4652+ } ) ;
46434653
4644- afterAll ( async ( ) => {
4645- await fs . promises . rm ( outputPath , {
4646- recursive : true ,
4647- force : true ,
4654+ // eslint-disable-next-line jest/no-duplicate-hooks
4655+ afterAll ( async ( ) => {
4656+ await fs . promises . rm ( outputPath , {
4657+ recursive : true ,
4658+ force : true ,
4659+ } ) ;
4660+ await close ( server , instance ) ;
46484661 } ) ;
4649- await close ( server , instance ) ;
4650- } ) ;
46514662
4652- it ( "should find the bundle files on disk" , async ( ) => {
4653- const response1 = await req . get ( "/static-one/bundle.js" ) ;
4663+ it ( "should find the bundle files on disk" , async ( ) => {
4664+ const response1 = await req . get ( "/static-one/bundle.js" ) ;
46544665
4655- expect ( response1 . statusCode ) . toBe ( 200 ) ;
4666+ expect ( response1 . statusCode ) . toBe ( 200 ) ;
46564667
4657- const response2 = await req . get ( "/static-two/bundle.js" ) ;
4668+ const response2 = await req . get ( "/static-two/bundle.js" ) ;
46584669
4659- expect ( response2 . statusCode ) . toBe ( 200 ) ;
4670+ expect ( response2 . statusCode ) . toBe ( 200 ) ;
46604671
4661- const bundleFiles = [
4662- "./outputs/write-to-disk-multi-compiler/static-one/bundle.js" ,
4663- "./outputs/write-to-disk-multi-compiler/static-one/index.html" ,
4664- "./outputs/write-to-disk-multi-compiler/static-one/svg.svg" ,
4665- "./outputs/write-to-disk-multi-compiler/static-two/bundle.js" ,
4666- ] ;
4672+ const bundleFiles = [
4673+ "./outputs/write-to-disk-multi-compiler/static-one/bundle.js" ,
4674+ "./outputs/write-to-disk-multi-compiler/static-one/index.html" ,
4675+ "./outputs/write-to-disk-multi-compiler/static-one/svg.svg" ,
4676+ "./outputs/write-to-disk-multi-compiler/static-two/bundle.js" ,
4677+ ] ;
46674678
4668- for ( const bundleFile of bundleFiles ) {
4669- const bundlePath = path . resolve ( __dirname , bundleFile ) ;
4679+ for ( const bundleFile of bundleFiles ) {
4680+ const bundlePath = path . resolve ( __dirname , bundleFile ) ;
46704681
4671- expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4672- }
4673- } ) ;
4674- } ) ;
4682+ expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4683+ }
4684+ } ) ;
4685+ } ,
4686+ ) ;
46754687
46764688 describe ( 'should work with "[hash]"/"[fullhash]" in the "output.path" and "output.publicPath" option' , ( ) => {
46774689 let compiler ;
0 commit comments