-
-
Notifications
You must be signed in to change notification settings - Fork 679
tests: add test for zero config #1418
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
7 commits
Select commit
Hold shift + click to select a range
ffc8a13
tests: add tests for zero config
anshumanv 5baf8a6
tests: add tests for zero config
anshumanv 05c8eff
tests: add tests for zero config
anshumanv ad1e9dc
tests: add tests for zero config
anshumanv 661f9a6
tests: add tests for zero config
anshumanv 7af3ff4
tests: add checks for existence of bundled file
anshumanv baf9ee9
Merge branch 'next' into 0cjs/tests
anshumanv 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
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,10 @@ | ||
| const { run } = require('../../utils/test-utils'); | ||
|
|
||
| describe('Zero Config tests', () => { | ||
| it('runs when config and entry are both absent', () => { | ||
| const { stdout, stderr } = run(__dirname, [], false); | ||
| // Entry file is absent, should log the Error from the compiler | ||
| expect(stdout).toContain("Error: Can't resolve './src'"); | ||
| expect(stderr).toBeFalsy(); | ||
| }); | ||
| }); |
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 @@ | ||
| console.log("Shoyo") |
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,16 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { run } = require('../../utils/test-utils'); | ||
|
|
||
| describe('Zero Config tests', () => { | ||
| it('runs when no config is supplied but entry is present', () => { | ||
| const { stdout, stderr } = run(__dirname, [], false); | ||
| // Should be able to find the entry file | ||
| expect(stdout).toContain('./src/index.js'); | ||
| // Should output at the default output dir and filename | ||
| expect(stdout).toContain('Entrypoint main = main.js'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already have it, only entry present and config absent. @evilebottnawi |
||
| // check that the output file exists | ||
| expect(fs.existsSync(path.join(__dirname, '/dist/main.js'))).toBeTruthy(); | ||
| expect(stderr).toBeFalsy(); | ||
| }); | ||
| }); | ||
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 @@ | ||
| console.log("Naruto") |
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,6 @@ | ||
| module.exports = { | ||
| mode: 'development', | ||
| output: { | ||
| filename: 'test-output.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,16 @@ | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { run } = require('../../utils/test-utils'); | ||
|
|
||
| describe('Zero Config', () => { | ||
| it('runs when config is present but not supplied via flag', () => { | ||
| const { stdout, stderr } = run(__dirname, [], false); | ||
| // default entry should be used | ||
| expect(stdout).toContain('./index.js'); | ||
| // should pick up the output path from config | ||
| expect(stdout).toContain('Entrypoint main = test-output'); | ||
| // check that the output file exists | ||
| expect(fs.existsSync(path.join(__dirname, '/dist/test-output.js'))).toBeTruthy(); | ||
| expect(stderr).toBeFalsy(); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also test for existence of bundle output file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can def do that, thinking if this would be the right scope for it as output file check is something which is config/flag agnostic. wdyt? Since we're not checking for it anywhere else, should be also checked for it in all other tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we can just check the test util since it's used everywhere, will add tests for the
runfn that we use in all tests separately. Would make more sense to check file existence there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case we should test it either way imo. Because the test is for checking whether without config we are bundling or not.
Tests for run as well in a different PR would be great :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're consuming the
runfn for couple of test cases where bundle output is not generated, say themigratecommand. It should be taken into account while writing the respective tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fair, added. 👍