1
- import { join } from 'path ' ;
1
+ import * as assert from 'yeoman-assert ' ;
2
2
import { run } from 'yeoman-test' ;
3
+ import { join } from 'path' ;
3
4
4
- // fixme: unstable
5
5
describe ( 'init generator' , ( ) => {
6
6
it ( 'generates a webpack project config' , async ( ) => {
7
7
const outputDir = await run ( join ( __dirname , '../src/init-generator' ) ) . withPrompts ( {
@@ -12,6 +12,16 @@ describe('init generator', () => {
12
12
stylingType : 'No' ,
13
13
useExtractPlugin : 'main' ,
14
14
} ) ;
15
+
16
+ // Check that all the project files are generated with the correct name
17
+ const filePaths = [ 'package.json' , 'README.md' , 'src/index2.js' ] ;
18
+ assert . file ( filePaths . map ( file => join ( outputDir , file ) ) ) ;
19
+
20
+ // Check generated file contents
21
+ assert . fileContent ( join ( outputDir , 'package.json' ) , '"name": "my-webpack-project"' ) ;
22
+ assert . fileContent ( join ( outputDir , 'README.md' ) , 'Welcome to your new awesome project!' ) ;
23
+ assert . fileContent ( join ( outputDir , 'src' , 'index2.js' ) , 'console.log("Hello World from your main file!");' ) ;
24
+
15
25
const output = require ( join ( outputDir , '.yo-rc.json' ) ) ;
16
26
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17
27
const config = ( Object . entries ( output ) [ 0 ] [ 1 ] as any ) . configuration . config . webpackOptions ;
0 commit comments