@@ -2,12 +2,7 @@ const os = require("os");
22const path = require ( "path" ) ;
33const { mkdirSync, existsSync, readFileSync } = require ( "fs" ) ;
44const { join, resolve } = require ( "path" ) ;
5- const {
6- createPathDependentUtils,
7- uniqueDirectoryForTest,
8- isWindows,
9- nodeVersion,
10- } = require ( "../test.utils.js" ) ;
5+ const { createPathDependentUtils, uniqueDirectoryForTest, isWindows } = require ( "../test.utils.js" ) ;
116const { run, runPromptWithAnswers } = createPathDependentUtils ( "create-webpack-app" ) ;
127
138jest . setTimeout ( 480000 ) ;
@@ -64,7 +59,7 @@ const readFromPkgJSON = (path) => {
6459// Helper to read from webpack.config.js in a given path
6560const readFromWebpackConfig = ( path ) => readFileSync ( join ( path , "webpack.config.js" ) , "utf8" ) ;
6661
67- ( nodeVersion >= 18 ? describe : describe . skip ) ( "create-webpack-app cli" , ( ) => {
62+ describe ( "create-webpack-app cli" , ( ) => {
6863 it ( "should generate default project when nothing is passed" , async ( ) => {
6964 const assetsPath = await uniqueDirectoryForTest ( ) ;
7065 const { stdout } = await run ( assetsPath , [ "init" , "--force" ] ) ;
@@ -94,7 +89,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
9489 // Check if the generated package.json file content matches the snapshot
9590 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
9691 } ) ;
97- //
92+
9893 it ( "should generate folders if non existing generation path is given" , async ( ) => {
9994 const assetsPath = path . resolve ( os . tmpdir ( ) , Date . now ( ) . toString ( ) ) ;
10095 const { stdout } = await run ( __dirname , [ "init" , assetsPath , "--force" ] ) ;
@@ -111,7 +106,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
111106 //Check if the generated package.json file content matches the snapshot
112107 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
113108 } ) ;
114- // //
109+
115110 it ( "should configure assets modules by default" , async ( ) => {
116111 const assetsPath = await uniqueDirectoryForTest ( ) ;
117112 const { stdout } = await run ( assetsPath , [ "init" , "--force" ] ) ;
@@ -129,7 +124,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
129124 // Check if the generated webpack configuration matches the snapshot
130125 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
131126 } ) ;
132- //
127+
133128 it ( "should ask question when wrong template is supplied" , async ( ) => {
134129 const assetsPath = await uniqueDirectoryForTest ( ) ;
135130 const { stdout, stderr } = await runPromptWithAnswers (
@@ -150,7 +145,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
150145 // Check if the generated package.json file content matches the snapshot
151146 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
152147 } ) ;
153- //
148+
154149 it ( "should generate typescript project correctly" , async ( ) => {
155150 const assetsPath = await uniqueDirectoryForTest ( ) ;
156151 const { stdout } = await runPromptWithAnswers (
@@ -180,7 +175,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
180175 // Check if the generated webpack configuration matches the snapshot
181176 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
182177 } ) ;
183- // //
178+
184179 it ( "should generate ES6 project correctly" , async ( ) => {
185180 const assetsPath = await uniqueDirectoryForTest ( ) ;
186181 const { stdout } = await runPromptWithAnswers (
@@ -206,7 +201,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
206201 // Check if the generated webpack configuration matches the snapshot
207202 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
208203 } ) ;
209- //
204+
210205 it ( "should use sass in project when selected" , async ( ) => {
211206 const assetsPath = await uniqueDirectoryForTest ( ) ;
212207 const { stdout } = await runPromptWithAnswers (
@@ -239,7 +234,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
239234 // Check if the generated webpack configuration matches the snapshot
240235 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
241236 } ) ;
242- //
237+
243238 it ( "should use sass with postcss in project when selected" , async ( ) => {
244239 const assetsPath = await uniqueDirectoryForTest ( ) ;
245240 const { stdout } = await runPromptWithAnswers (
@@ -274,7 +269,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
274269 // Check if the generated webpack configuration matches the snapshot
275270 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
276271 } ) ;
277- //
272+
278273 it ( "should use mini-css-extract-plugin when selected" , async ( ) => {
279274 const assetsPath = await uniqueDirectoryForTest ( ) ;
280275 const { stdout } = await runPromptWithAnswers (
@@ -307,7 +302,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
307302 // Check if the generated webpack configuration matches the snapshot
308303 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
309304 } ) ;
310- //
305+
311306 it ( "should use sass and css with postcss in project when selected" , async ( ) => {
312307 const assetsPath = await uniqueDirectoryForTest ( ) ;
313308 const { stdout } = await runPromptWithAnswers (
@@ -342,7 +337,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
342337 // Check if the generated webpack configuration matches the snapshot
343338 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
344339 } ) ;
345- //
340+
346341 it ( "should use less in project when selected" , async ( ) => {
347342 const assetsPath = await uniqueDirectoryForTest ( ) ;
348343 const { stdout } = await runPromptWithAnswers (
@@ -375,7 +370,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
375370 // Check if the generated webpack configuration matches the snapshot
376371 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
377372 } ) ;
378- // //
373+
379374 it ( "should use stylus in project when selected" , async ( ) => {
380375 const assetsPath = await uniqueDirectoryForTest ( ) ;
381376 const { stdout } = await runPromptWithAnswers (
@@ -408,7 +403,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
408403 // Check if the generated webpack configuration matches the snapshot
409404 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
410405 } ) ;
411- // //
406+
412407 it ( "should configure WDS as opted" , async ( ) => {
413408 const assetsPath = await uniqueDirectoryForTest ( ) ;
414409 const { stdout } = await runPromptWithAnswers (
@@ -432,7 +427,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
432427 // Check if the generated webpack configuration matches the snapshot
433428 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
434429 } ) ;
435- // //
430+
436431 it ( "should use postcss in project when selected" , async ( ) => {
437432 const assetsPath = await uniqueDirectoryForTest ( ) ;
438433 const { stdout } = await runPromptWithAnswers (
@@ -466,7 +461,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
466461 // Check if the generated webpack configuration matches the snapshot
467462 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
468463 } ) ;
469- //
464+
470465 it ( "should configure html-webpack-plugin as opted" , async ( ) => {
471466 const assetsPath = await uniqueDirectoryForTest ( ) ;
472467 const { stdout } = await runPromptWithAnswers (
@@ -490,7 +485,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
490485 // Check if the generated webpack configuration matches the snapshot
491486 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
492487 } ) ;
493- //
488+
494489 it ( "should configure workbox-webpack-plugin as opted" , async ( ) => {
495490 const assetsPath = await uniqueDirectoryForTest ( ) ;
496491 const { stdout } = await runPromptWithAnswers (
@@ -514,7 +509,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
514509 // Check if the generated webpack configuration matches the snapshot
515510 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
516511 } ) ;
517- //
512+
518513 it ( "should throw if the current path is not writable" , async ( ) => {
519514 if ( isWindows ) {
520515 return ;
@@ -530,7 +525,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
530525 expect ( stderr ) . toContain ( "Failed to initialize the project with webpack!" ) ;
531526 expect ( exitCode ) . toBe ( 2 ) ;
532527 } ) ;
533- //
528+
534529 it ( "should work with 'new' alias" , async ( ) => {
535530 const assetsPath = await uniqueDirectoryForTest ( ) ;
536531 const { stdout } = await run ( assetsPath , [ "new" , "--force" ] ) ;
@@ -546,7 +541,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
546541 // Check if the generated package.json file content matches the snapshot
547542 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
548543 } ) ;
549- //
544+
550545 it ( "should work with 'create' alias" , async ( ) => {
551546 const assetsPath = await uniqueDirectoryForTest ( ) ;
552547 const { stdout } = await run ( assetsPath , [ "create" , "--force" ] ) ;
@@ -562,7 +557,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
562557 // Check if the generated package.json file content matches the snapshot
563558 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
564559 } ) ;
565- //
560+
566561 it ( "should work with 'c' alias" , async ( ) => {
567562 const assetsPath = await uniqueDirectoryForTest ( ) ;
568563 const { stdout } = await run ( assetsPath , [ "c" , "--force" ] ) ;
@@ -578,7 +573,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
578573 // Check if the generated package.json file content matches the snapshot
579574 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
580575 } ) ;
581- //
576+
582577 it ( "should work with 'n' alias" , async ( ) => {
583578 const assetsPath = await uniqueDirectoryForTest ( ) ;
584579 const { stdout } = await run ( assetsPath , [ "n" , "--force" ] ) ;
@@ -626,7 +621,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
626621 // Check if the generated package.json file content matches the snapshot
627622 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
628623 } ) ;
629- //
624+
630625 it ( "uses yarn as the package manager when opted" , async ( ) => {
631626 const assetsPath = await uniqueDirectoryForTest ( ) ;
632627 const { stdout } = await runPromptWithAnswers (
@@ -651,7 +646,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
651646 // Check if the generated package.json file content matches the snapshot
652647 expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
653648 } ) ;
654- //
649+
655650 it ( "should generate react template with state and routing support with prompt answers" , async ( ) => {
656651 const assetsPath = await uniqueDirectoryForTest ( ) ;
657652 const { stdout } = await runPromptWithAnswers (
@@ -674,7 +669,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
674669 // Check if the generated webpack configuration matches the snapshot
675670 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
676671 } ) ;
677- //
672+
678673 it ( "should generate react template with --force" , async ( ) => {
679674 const assetsPath = await uniqueDirectoryForTest ( ) ;
680675 const { stdout } = await run ( assetsPath , [ "init" , "--template=react" , "--force" ] ) ;
@@ -737,6 +732,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
737732 // Check if the generated webpack configuration matches the snapshot
738733 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
739734 } ) ;
735+
740736 it ( "should generate svelte template with prompt answers" , async ( ) => {
741737 const assetsPath = await uniqueDirectoryForTest ( ) ;
742738 const { stdout } = await runPromptWithAnswers (
@@ -759,6 +755,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
759755 // Check if the generated webpack configuration matches the snapshot
760756 expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
761757 } ) ;
758+
762759 it ( "should generate svelte template with --force" , async ( ) => {
763760 const assetsPath = await uniqueDirectoryForTest ( ) ;
764761 const { stdout } = await run ( assetsPath , [ "init" , "--template=svelte" , "--force" ] ) ;
0 commit comments