@@ -4325,86 +4325,81 @@ describe.each([
43254325 } ) ;
43264326
43274327 describe ( "writeToDisk option" , ( ) => {
4328- // TODO https://github.com/honojs/node-server/issues/233
4329- ( name === "hono" ? describe . skip : describe ) (
4330- 'should work with "true" value' ,
4331- ( ) => {
4332- let compiler ;
4333-
4334- const outputPath = path . resolve (
4335- __dirname ,
4336- "./outputs/write-to-disk-true" ,
4337- ) ;
4328+ describe ( 'should work with "true" value' , ( ) => {
4329+ let compiler ;
43384330
4339- beforeAll ( async ( ) => {
4340- compiler = getCompiler ( {
4341- ...webpackConfig ,
4342- output : {
4343- filename : "bundle.js" ,
4344- path : outputPath ,
4345- publicPath : "/public/" ,
4346- } ,
4347- } ) ;
4331+ const outputPath = path . resolve (
4332+ __dirname ,
4333+ "./outputs/write-to-disk-true" ,
4334+ ) ;
43484335
4349- [ server , req , instance ] = await frameworkFactory (
4350- name ,
4351- framework ,
4352- compiler ,
4353- { writeToDisk : true } ,
4354- ) ;
4336+ beforeAll ( async ( ) => {
4337+ compiler = getCompiler ( {
4338+ ...webpackConfig ,
4339+ output : {
4340+ filename : "bundle.js" ,
4341+ path : outputPath ,
4342+ publicPath : "/public/" ,
4343+ } ,
43554344 } ) ;
43564345
4357- afterAll ( async ( ) => {
4358- await fs . promises . rm ( outputPath , {
4359- recursive : true ,
4360- force : true ,
4361- } ) ;
4362- await close ( server , instance ) ;
4346+ [ server , req , instance ] = await frameworkFactory (
4347+ name ,
4348+ framework ,
4349+ compiler ,
4350+ { writeToDisk : true } ,
4351+ ) ;
4352+ } ) ;
4353+
4354+ afterAll ( async ( ) => {
4355+ await fs . promises . rm ( outputPath , {
4356+ recursive : true ,
4357+ force : true ,
43634358 } ) ;
4359+ await close ( server , instance ) ;
4360+ } ) ;
43644361
4365- it ( "should find the bundle file on disk" , ( done ) => {
4366- req . get ( "/public/bundle.js" ) . expect ( 200 , ( error ) => {
4367- if ( error ) {
4368- return done ( error ) ;
4369- }
4362+ it ( "should find the bundle file on disk" , ( done ) => {
4363+ req . get ( "/public/bundle.js" ) . expect ( 200 , ( error ) => {
4364+ if ( error ) {
4365+ return done ( error ) ;
4366+ }
43704367
4371- const bundlePath = path . resolve (
4372- __dirname ,
4373- "./outputs/write-to-disk-true/bundle.js" ,
4374- ) ;
4368+ const bundlePath = path . resolve (
4369+ __dirname ,
4370+ "./outputs/write-to-disk-true/bundle.js" ,
4371+ ) ;
43754372
4373+ expect (
4374+ compiler . hooks . assetEmitted . taps . filter (
4375+ ( hook ) => hook . name === "DevMiddleware" ,
4376+ ) ,
4377+ ) . toHaveLength ( 0 ) ;
4378+
4379+ expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4380+
4381+ compiler . hooks . done . tap ( "DevMiddlewareWriteToDiskTest" , ( ) => {
43764382 expect (
43774383 compiler . hooks . assetEmitted . taps . filter (
43784384 ( hook ) => hook . name === "DevMiddleware" ,
43794385 ) ,
43804386 ) . toHaveLength ( 0 ) ;
4387+ } ) ;
43814388
4382- expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4383-
4384- compiler . hooks . done . tap ( "DevMiddlewareWriteToDiskTest" , ( ) => {
4385- expect (
4386- compiler . hooks . assetEmitted . taps . filter (
4387- ( hook ) => hook . name === "DevMiddleware" ,
4388- ) ,
4389- ) . toHaveLength ( 0 ) ;
4390- } ) ;
4391-
4392- instance . invalidate ( ( ) => {
4393- done ( ) ;
4394- } ) ;
4389+ instance . invalidate ( ( ) => {
4390+ done ( ) ;
43954391 } ) ;
43964392 } ) ;
4393+ } ) ;
43974394
4398- it ( "should not allow to get files above root" , async ( ) => {
4399- const response = await req . get (
4400- "/public/..%2f../middleware.test.js" ,
4401- ) ;
4395+ it ( "should not allow to get files above root" , async ( ) => {
4396+ const response = await req . get ( "/public/..%2f../middleware.test.js" ) ;
44024397
4403- expect ( response . statusCode ) . toBe ( 403 ) ;
4404- expect ( response . headers [ "content-type" ] ) . toBe (
4405- "text/html; charset=utf-8" ,
4406- ) ;
4407- expect ( response . text ) . toBe ( `<!DOCTYPE html>
4398+ expect ( response . statusCode ) . toBe ( 403 ) ;
4399+ expect ( response . headers [ "content-type" ] ) . toBe (
4400+ "text/html; charset=utf-8" ,
4401+ ) ;
4402+ expect ( response . text ) . toBe ( `<!DOCTYPE html>
44084403<html lang="en">
44094404<head>
44104405<meta charset="utf-8">
@@ -4414,9 +4409,8 @@ describe.each([
44144409<pre>Forbidden</pre>
44154410</body>
44164411</html>` ) ;
4417- } ) ;
4418- } ,
4419- ) ;
4412+ } ) ;
4413+ } ) ;
44204414
44214415 describe ( 'should work with "true" value when the `output.clean` is `true`' , ( ) => {
44224416 const outputPath = path . resolve (
@@ -4697,85 +4691,79 @@ describe.each([
46974691 } ) ;
46984692 } ) ;
46994693
4700- // TODO https://github.com/honojs/node-server/issues/233
4701- ( name === "hono" ? describe . skip : describe ) (
4702- "should work in multi-compiler mode" ,
4703- ( ) => {
4704- let compiler ;
4694+ describe ( "should work in multi-compiler mode" , ( ) => {
4695+ let compiler ;
47054696
4706- const outputPath = path . resolve (
4707- __dirname ,
4708- "./outputs/write-to-disk-multi-compiler/" ,
4709- ) ;
4697+ const outputPath = path . resolve (
4698+ __dirname ,
4699+ "./outputs/write-to-disk-multi-compiler/" ,
4700+ ) ;
47104701
4711- // eslint-disable-next-line jest/no-duplicate-hooks
4712- beforeAll ( async ( ) => {
4713- compiler = getCompiler ( [
4714- {
4715- ...webpackMultiWatchOptionsConfig [ 0 ] ,
4716- output : {
4717- filename : "bundle.js" ,
4718- path : path . resolve (
4719- __dirname ,
4720- "./outputs/write-to-disk-multi-compiler/static-one" ,
4721- ) ,
4722- publicPath : "/static-one/" ,
4723- } ,
4702+ beforeAll ( async ( ) => {
4703+ compiler = getCompiler ( [
4704+ {
4705+ ...webpackMultiWatchOptionsConfig [ 0 ] ,
4706+ output : {
4707+ filename : "bundle.js" ,
4708+ path : path . resolve (
4709+ __dirname ,
4710+ "./outputs/write-to-disk-multi-compiler/static-one" ,
4711+ ) ,
4712+ publicPath : "/static-one/" ,
47244713 } ,
4725- {
4726- ... webpackMultiWatchOptionsConfig [ 1 ] ,
4727- output : {
4728- filename : "bundle.js" ,
4729- path : path . resolve (
4730- __dirname ,
4731- "./outputs/write-to-disk-multi-compiler/static-two" ,
4732- ) ,
4733- publicPath : "/static-two/" ,
4734- } ,
4714+ } ,
4715+ {
4716+ ... webpackMultiWatchOptionsConfig [ 1 ] ,
4717+ output : {
4718+ filename : "bundle.js" ,
4719+ path : path . resolve (
4720+ __dirname ,
4721+ "./outputs/write-to-disk-multi-compiler/static-two" ,
4722+ ) ,
4723+ publicPath : "/static-two/" ,
47354724 } ,
4736- ] ) ;
4725+ } ,
4726+ ] ) ;
47374727
4738- [ server , req , instance ] = await frameworkFactory (
4739- name ,
4740- framework ,
4741- compiler ,
4742- { writeToDisk : true } ,
4743- ) ;
4744- } ) ;
4728+ [ server , req , instance ] = await frameworkFactory (
4729+ name ,
4730+ framework ,
4731+ compiler ,
4732+ { writeToDisk : true } ,
4733+ ) ;
4734+ } ) ;
47454735
4746- // eslint-disable-next-line jest/no-duplicate-hooks
4747- afterAll ( async ( ) => {
4748- await fs . promises . rm ( outputPath , {
4749- recursive : true ,
4750- force : true ,
4751- } ) ;
4752- await close ( server , instance ) ;
4736+ afterAll ( async ( ) => {
4737+ await fs . promises . rm ( outputPath , {
4738+ recursive : true ,
4739+ force : true ,
47534740 } ) ;
4741+ await close ( server , instance ) ;
4742+ } ) ;
47544743
4755- it ( "should find the bundle files on disk" , async ( ) => {
4756- const response1 = await req . get ( "/static-one/bundle.js" ) ;
4744+ it ( "should find the bundle files on disk" , async ( ) => {
4745+ const response1 = await req . get ( "/static-one/bundle.js" ) ;
47574746
4758- expect ( response1 . statusCode ) . toBe ( 200 ) ;
4747+ expect ( response1 . statusCode ) . toBe ( 200 ) ;
47594748
4760- const response2 = await req . get ( "/static-two/bundle.js" ) ;
4749+ const response2 = await req . get ( "/static-two/bundle.js" ) ;
47614750
4762- expect ( response2 . statusCode ) . toBe ( 200 ) ;
4751+ expect ( response2 . statusCode ) . toBe ( 200 ) ;
47634752
4764- const bundleFiles = [
4765- "./outputs/write-to-disk-multi-compiler/static-one/bundle.js" ,
4766- "./outputs/write-to-disk-multi-compiler/static-one/index.html" ,
4767- "./outputs/write-to-disk-multi-compiler/static-one/svg.svg" ,
4768- "./outputs/write-to-disk-multi-compiler/static-two/bundle.js" ,
4769- ] ;
4753+ const bundleFiles = [
4754+ "./outputs/write-to-disk-multi-compiler/static-one/bundle.js" ,
4755+ "./outputs/write-to-disk-multi-compiler/static-one/index.html" ,
4756+ "./outputs/write-to-disk-multi-compiler/static-one/svg.svg" ,
4757+ "./outputs/write-to-disk-multi-compiler/static-two/bundle.js" ,
4758+ ] ;
47704759
4771- for ( const bundleFile of bundleFiles ) {
4772- const bundlePath = path . resolve ( __dirname , bundleFile ) ;
4760+ for ( const bundleFile of bundleFiles ) {
4761+ const bundlePath = path . resolve ( __dirname , bundleFile ) ;
47734762
4774- expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4775- }
4776- } ) ;
4777- } ,
4778- ) ;
4763+ expect ( fs . existsSync ( bundlePath ) ) . toBe ( true ) ;
4764+ }
4765+ } ) ;
4766+ } ) ;
47794767
47804768 describe ( 'should work with "[hash]"/"[fullhash]" in the "output.path" and "output.publicPath" option' , ( ) => {
47814769 let compiler ;
@@ -5076,8 +5064,7 @@ describe.each([
50765064 framework ,
50775065 compiler ,
50785066 {
5079- // eslint-disable-next-line no-unused-vars
5080- headers : ( req , res , context ) => {
5067+ headers : ( req , res ) => {
50815068 res . setHeader ( "X-nonsense-1" , "yes" ) ;
50825069 res . setHeader ( "X-nonsense-2" , "no" ) ;
50835070 } ,
0 commit comments