-
-
Notifications
You must be signed in to change notification settings - Fork 679
tests: add tests for init #1419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
058949a
chore: add init tests
rishabh3112 f5586b6
chore: lint
rishabh3112 f8db30f
chore: lint
rishabh3112 900ca34
tests: add init test with cli flags
rishabh3112 d3b7476
chore: add e2e test for init
rishabh3112 86a2a80
chore: remove console log
rishabh3112 6f74ea1
chore: use root gitignore
rishabh3112 43351bb
chore: move tests to __tests__
rishabh3112 5f513cb
chore: move functions to test utils
rishabh3112 1584c3e
chore: add timeout
rishabh3112 4aa8113
chore: use webpack-cli gitignore
rishabh3112 afb28c0
chore: try debugging macos
rishabh3112 3fdea19
chore: skip one test for debug
rishabh3112 6e0a3c0
chore: remove skip
rishabh3112 9600bfb
chore: remove debug logs
rishabh3112 2a28880
Merge branch 'next' into chore/test-init
jamesgeorge007 7a5d4b2
chore: correct typo
rishabh3112 e828dda
Merge branch 'chore/test-init' of https://github.com/webpack/webpack-…
rishabh3112 4032b9d
Merge branch 'next' into chore/test-init
rishabh3112 f56fc0d
chore: add jsdoc comment
rishabh3112 a1d4dd9
Merge branch 'chore/test-init' of https://github.com/webpack/webpack-…
rishabh3112 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,3 +54,4 @@ packages/**/*.map | |
|
|
||
| # temporary test files | ||
| test-assets/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/webpack-cli/__tests__/init/auto/init-auto.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* eslint-disable node/no-unpublished-require */ | ||
| 'use strict'; | ||
|
|
||
| const firstPrompt = 'Will your application have multiple bundles?'; | ||
| const fs = require('fs'); | ||
| const { join } = require('path'); | ||
| const { run } = require('../../../../../test/utils/test-utils'); | ||
|
|
||
| jest.setTimeout(200000); | ||
| describe('init auto flag', () => { | ||
| it('should prompt with w/o auto flag', () => { | ||
| const { stdout, stderr } = run(__dirname, ['init'], false); | ||
| expect(stdout).toBeTruthy(); | ||
| expect(stderr).toBeFalsy(); | ||
| expect(stdout).toContain(firstPrompt); | ||
| }); | ||
|
|
||
| it('should scaffold and not prompt with auto flag', () => { | ||
| const { stdout } = run(__dirname, ['init', '--auto'], false); | ||
| // Test no prompts are present | ||
| expect(stdout).toBeTruthy(); | ||
| expect(stdout).not.toContain(firstPrompt); | ||
|
|
||
| // Test regressively files are scaffolded | ||
| const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; | ||
| // eslint-disable-next-line prettier/prettier | ||
| files.forEach((file) => { | ||
| expect(fs.existsSync(join(__dirname, file))).toBeTruthy(); | ||
| }); | ||
| }); | ||
| }); | ||
15 changes: 15 additions & 0 deletions
15
packages/webpack-cli/__tests__/init/coreFlags/init-flags.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /* eslint-disable node/no-unpublished-require */ | ||
| 'use strict'; | ||
|
|
||
| const firstPrompt = 'Will your application have multiple bundles?'; | ||
| const { run } = require('../../../../../test/utils/test-utils'); | ||
|
|
||
| describe('init with core flags', () => { | ||
| it('should output help with --help flag', () => { | ||
| const { stdout, stderr } = run(__dirname, ['init', '--help'], false); | ||
| expect(stdout).toBeTruthy(); | ||
| expect(stderr).toBeFalsy(); | ||
| expect(stdout).not.toContain(firstPrompt); | ||
| expect(stdout).toContain('Initialize a new webpack configuration'); | ||
| }); | ||
| }); |
27 changes: 27 additions & 0 deletions
27
packages/webpack-cli/__tests__/init/generator/init-inquirer.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* eslint-disable node/no-unpublished-require */ | ||
| 'use strict'; | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { runInitWithAnswers } = require('../../../../../test/utils/test-utils'); | ||
| const firstPrompt = 'Will your application have multiple bundles?'; | ||
|
|
||
| const ENTER = '\x0D'; | ||
|
|
||
| jest.setTimeout(200000); | ||
|
|
||
| describe('init', () => { | ||
| it('should scaffold when given answers', async () => { | ||
| const stdout = await runInitWithAnswers(__dirname, ['N', ENTER, ENTER, ENTER, ENTER, ENTER, ENTER, ENTER]); | ||
|
|
||
| expect(stdout).toBeTruthy(); | ||
| expect(stdout).toContain(firstPrompt); | ||
|
|
||
| // Test regressively files are scaffolded | ||
| const files = ['./sw.js', './package.json', './yarn.lock', './src/index.js']; | ||
| // eslint-disable-next-line prettier/prettier | ||
| files.forEach((file) => { | ||
| expect(fs.existsSync(path.join(__dirname, file))).toBeTruthy(); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.