diff --git a/packages/generators/__tests__/init-generator.test.ts b/packages/generators/__tests__/init-generator.test.ts index 0b294ab2554..20cc421642d 100644 --- a/packages/generators/__tests__/init-generator.test.ts +++ b/packages/generators/__tests__/init-generator.test.ts @@ -1,7 +1,7 @@ -import { join } from 'path'; +import * as assert from 'yeoman-assert'; import { run } from 'yeoman-test'; +import { join } from 'path'; -// fixme: unstable describe('init generator', () => { it('generates a webpack project config', async () => { const outputDir = await run(join(__dirname, '../src/init-generator')).withPrompts({ @@ -12,6 +12,16 @@ describe('init generator', () => { stylingType: 'No', useExtractPlugin: 'main', }); + + // Check that all the project files are generated with the correct name + const filePaths = ['package.json', 'README.md', 'src/index2.js']; + assert.file(filePaths.map(file => join(outputDir, file))); + + // Check generated file contents + assert.fileContent(join(outputDir, 'package.json'), '"name": "my-webpack-project"'); + assert.fileContent(join(outputDir, 'README.md'), 'Welcome to your new awesome project!'); + assert.fileContent(join(outputDir, 'src', 'index2.js'), 'console.log("Hello World from your main file!");'); + const output = require(join(outputDir, '.yo-rc.json')); // eslint-disable-next-line @typescript-eslint/no-explicit-any const config = (Object.entries(output)[0][1] as any).configuration.config.webpackOptions; diff --git a/packages/generators/package.json b/packages/generators/package.json index c884a5f9480..8a6107df536 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -35,12 +35,12 @@ "@types/mkdirp": "0.5.2", "@types/node": "12.7.2", "@types/webpack-dev-server": "3.1.7", + "@types/yeoman-assert": "^3.1.1", "@types/yeoman-generator": "3.1.4", "@types/yeoman-test": "2.0.3", - "@types/yeoman-assert": "^3.1.1", "typescript": "3.5.3", - "yeoman-test": "2.1.0", - "yeoman-assert": "^3.1.1" + "yeoman-assert": "^3.1.1", + "yeoman-test": "2.1.0" }, "scripts": { "build": "tsc",