@@ -2,12 +2,7 @@ const os = require("os");
2
2
const path = require ( "path" ) ;
3
3
const { mkdirSync, existsSync, readFileSync } = require ( "fs" ) ;
4
4
const { 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" ) ;
11
6
const { run, runPromptWithAnswers } = createPathDependentUtils ( "create-webpack-app" ) ;
12
7
13
8
jest . setTimeout ( 480000 ) ;
@@ -64,7 +59,7 @@ const readFromPkgJSON = (path) => {
64
59
// Helper to read from webpack.config.js in a given path
65
60
const readFromWebpackConfig = ( path ) => readFileSync ( join ( path , "webpack.config.js" ) , "utf8" ) ;
66
61
67
- ( nodeVersion >= 18 ? describe : describe . skip ) ( "create-webpack-app cli" , ( ) => {
62
+ describe ( "create-webpack-app cli" , ( ) => {
68
63
it ( "should generate default project when nothing is passed" , async ( ) => {
69
64
const assetsPath = await uniqueDirectoryForTest ( ) ;
70
65
const { stdout } = await run ( assetsPath , [ "init" , "--force" ] ) ;
@@ -94,7 +89,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
94
89
// Check if the generated package.json file content matches the snapshot
95
90
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
96
91
} ) ;
97
- //
92
+
98
93
it ( "should generate folders if non existing generation path is given" , async ( ) => {
99
94
const assetsPath = path . resolve ( os . tmpdir ( ) , Date . now ( ) . toString ( ) ) ;
100
95
const { stdout } = await run ( __dirname , [ "init" , assetsPath , "--force" ] ) ;
@@ -111,7 +106,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
111
106
//Check if the generated package.json file content matches the snapshot
112
107
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
113
108
} ) ;
114
- // //
109
+
115
110
it ( "should configure assets modules by default" , async ( ) => {
116
111
const assetsPath = await uniqueDirectoryForTest ( ) ;
117
112
const { stdout } = await run ( assetsPath , [ "init" , "--force" ] ) ;
@@ -129,7 +124,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
129
124
// Check if the generated webpack configuration matches the snapshot
130
125
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
131
126
} ) ;
132
- //
127
+
133
128
it ( "should ask question when wrong template is supplied" , async ( ) => {
134
129
const assetsPath = await uniqueDirectoryForTest ( ) ;
135
130
const { stdout, stderr } = await runPromptWithAnswers (
@@ -150,7 +145,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
150
145
// Check if the generated package.json file content matches the snapshot
151
146
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
152
147
} ) ;
153
- //
148
+
154
149
it ( "should generate typescript project correctly" , async ( ) => {
155
150
const assetsPath = await uniqueDirectoryForTest ( ) ;
156
151
const { stdout } = await runPromptWithAnswers (
@@ -180,7 +175,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
180
175
// Check if the generated webpack configuration matches the snapshot
181
176
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
182
177
} ) ;
183
- // //
178
+
184
179
it ( "should generate ES6 project correctly" , async ( ) => {
185
180
const assetsPath = await uniqueDirectoryForTest ( ) ;
186
181
const { stdout } = await runPromptWithAnswers (
@@ -206,7 +201,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
206
201
// Check if the generated webpack configuration matches the snapshot
207
202
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
208
203
} ) ;
209
- //
204
+
210
205
it ( "should use sass in project when selected" , async ( ) => {
211
206
const assetsPath = await uniqueDirectoryForTest ( ) ;
212
207
const { stdout } = await runPromptWithAnswers (
@@ -239,7 +234,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
239
234
// Check if the generated webpack configuration matches the snapshot
240
235
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
241
236
} ) ;
242
- //
237
+
243
238
it ( "should use sass with postcss in project when selected" , async ( ) => {
244
239
const assetsPath = await uniqueDirectoryForTest ( ) ;
245
240
const { stdout } = await runPromptWithAnswers (
@@ -274,7 +269,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
274
269
// Check if the generated webpack configuration matches the snapshot
275
270
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
276
271
} ) ;
277
- //
272
+
278
273
it ( "should use mini-css-extract-plugin when selected" , async ( ) => {
279
274
const assetsPath = await uniqueDirectoryForTest ( ) ;
280
275
const { stdout } = await runPromptWithAnswers (
@@ -307,7 +302,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
307
302
// Check if the generated webpack configuration matches the snapshot
308
303
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
309
304
} ) ;
310
- //
305
+
311
306
it ( "should use sass and css with postcss in project when selected" , async ( ) => {
312
307
const assetsPath = await uniqueDirectoryForTest ( ) ;
313
308
const { stdout } = await runPromptWithAnswers (
@@ -342,7 +337,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
342
337
// Check if the generated webpack configuration matches the snapshot
343
338
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
344
339
} ) ;
345
- //
340
+
346
341
it ( "should use less in project when selected" , async ( ) => {
347
342
const assetsPath = await uniqueDirectoryForTest ( ) ;
348
343
const { stdout } = await runPromptWithAnswers (
@@ -375,7 +370,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
375
370
// Check if the generated webpack configuration matches the snapshot
376
371
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
377
372
} ) ;
378
- // //
373
+
379
374
it ( "should use stylus in project when selected" , async ( ) => {
380
375
const assetsPath = await uniqueDirectoryForTest ( ) ;
381
376
const { stdout } = await runPromptWithAnswers (
@@ -408,7 +403,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
408
403
// Check if the generated webpack configuration matches the snapshot
409
404
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
410
405
} ) ;
411
- // //
406
+
412
407
it ( "should configure WDS as opted" , async ( ) => {
413
408
const assetsPath = await uniqueDirectoryForTest ( ) ;
414
409
const { stdout } = await runPromptWithAnswers (
@@ -432,7 +427,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
432
427
// Check if the generated webpack configuration matches the snapshot
433
428
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
434
429
} ) ;
435
- // //
430
+
436
431
it ( "should use postcss in project when selected" , async ( ) => {
437
432
const assetsPath = await uniqueDirectoryForTest ( ) ;
438
433
const { stdout } = await runPromptWithAnswers (
@@ -466,7 +461,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
466
461
// Check if the generated webpack configuration matches the snapshot
467
462
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
468
463
} ) ;
469
- //
464
+
470
465
it ( "should configure html-webpack-plugin as opted" , async ( ) => {
471
466
const assetsPath = await uniqueDirectoryForTest ( ) ;
472
467
const { stdout } = await runPromptWithAnswers (
@@ -490,7 +485,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
490
485
// Check if the generated webpack configuration matches the snapshot
491
486
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
492
487
} ) ;
493
- //
488
+
494
489
it ( "should configure workbox-webpack-plugin as opted" , async ( ) => {
495
490
const assetsPath = await uniqueDirectoryForTest ( ) ;
496
491
const { stdout } = await runPromptWithAnswers (
@@ -514,7 +509,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
514
509
// Check if the generated webpack configuration matches the snapshot
515
510
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
516
511
} ) ;
517
- //
512
+
518
513
it ( "should throw if the current path is not writable" , async ( ) => {
519
514
if ( isWindows ) {
520
515
return ;
@@ -530,7 +525,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
530
525
expect ( stderr ) . toContain ( "Failed to initialize the project with webpack!" ) ;
531
526
expect ( exitCode ) . toBe ( 2 ) ;
532
527
} ) ;
533
- //
528
+
534
529
it ( "should work with 'new' alias" , async ( ) => {
535
530
const assetsPath = await uniqueDirectoryForTest ( ) ;
536
531
const { stdout } = await run ( assetsPath , [ "new" , "--force" ] ) ;
@@ -546,7 +541,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
546
541
// Check if the generated package.json file content matches the snapshot
547
542
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
548
543
} ) ;
549
- //
544
+
550
545
it ( "should work with 'create' alias" , async ( ) => {
551
546
const assetsPath = await uniqueDirectoryForTest ( ) ;
552
547
const { stdout } = await run ( assetsPath , [ "create" , "--force" ] ) ;
@@ -562,7 +557,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
562
557
// Check if the generated package.json file content matches the snapshot
563
558
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
564
559
} ) ;
565
- //
560
+
566
561
it ( "should work with 'c' alias" , async ( ) => {
567
562
const assetsPath = await uniqueDirectoryForTest ( ) ;
568
563
const { stdout } = await run ( assetsPath , [ "c" , "--force" ] ) ;
@@ -578,7 +573,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
578
573
// Check if the generated package.json file content matches the snapshot
579
574
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
580
575
} ) ;
581
- //
576
+
582
577
it ( "should work with 'n' alias" , async ( ) => {
583
578
const assetsPath = await uniqueDirectoryForTest ( ) ;
584
579
const { stdout } = await run ( assetsPath , [ "n" , "--force" ] ) ;
@@ -626,7 +621,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
626
621
// Check if the generated package.json file content matches the snapshot
627
622
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
628
623
} ) ;
629
- //
624
+
630
625
it ( "uses yarn as the package manager when opted" , async ( ) => {
631
626
const assetsPath = await uniqueDirectoryForTest ( ) ;
632
627
const { stdout } = await runPromptWithAnswers (
@@ -651,7 +646,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
651
646
// Check if the generated package.json file content matches the snapshot
652
647
expect ( readFromPkgJSON ( assetsPath ) ) . toMatchSnapshot ( ) ;
653
648
} ) ;
654
- //
649
+
655
650
it ( "should generate react template with state and routing support with prompt answers" , async ( ) => {
656
651
const assetsPath = await uniqueDirectoryForTest ( ) ;
657
652
const { stdout } = await runPromptWithAnswers (
@@ -674,7 +669,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
674
669
// Check if the generated webpack configuration matches the snapshot
675
670
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
676
671
} ) ;
677
- //
672
+
678
673
it ( "should generate react template with --force" , async ( ) => {
679
674
const assetsPath = await uniqueDirectoryForTest ( ) ;
680
675
const { stdout } = await run ( assetsPath , [ "init" , "--template=react" , "--force" ] ) ;
@@ -737,6 +732,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
737
732
// Check if the generated webpack configuration matches the snapshot
738
733
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
739
734
} ) ;
735
+
740
736
it ( "should generate svelte template with prompt answers" , async ( ) => {
741
737
const assetsPath = await uniqueDirectoryForTest ( ) ;
742
738
const { stdout } = await runPromptWithAnswers (
@@ -759,6 +755,7 @@ const readFromWebpackConfig = (path) => readFileSync(join(path, "webpack.config.
759
755
// Check if the generated webpack configuration matches the snapshot
760
756
expect ( readFromWebpackConfig ( assetsPath ) ) . toMatchSnapshot ( ) ;
761
757
} ) ;
758
+
762
759
it ( "should generate svelte template with --force" , async ( ) => {
763
760
const assetsPath = await uniqueDirectoryForTest ( ) ;
764
761
const { stdout } = await run ( assetsPath , [ "init" , "--template=svelte" , "--force" ] ) ;
0 commit comments