-
-
Notifications
You must be signed in to change notification settings - Fork 616
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add tests for entry in config (#1718)
- Loading branch information
Showing
5 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
test/entry/config-entry/entry-with-index/entry-with-config.test.js
This file contains 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,24 @@ | ||
'use strict'; | ||
const { join } = require('path'); | ||
const { existsSync } = require('fs'); | ||
const { run } = require('../../../utils/test-utils'); | ||
|
||
describe('default entry and config entry all exist', () => { | ||
it('should use config entry if config entry existed', () => { | ||
const { stdout, stderr } = run(__dirname, [], false); | ||
// Should contain the relevant entry | ||
expect(stdout).toContain('./src/app.js'); | ||
expect(stdout).toContain('./src/print.js'); | ||
|
||
// Should contain the relevant bundle | ||
expect(stdout).toContain('app.bundle.js'); | ||
expect(stdout).toContain('print.bundle.js'); | ||
expect(stdout).not.toContain('index.js'); | ||
// Should only generate the files as per the entry in config | ||
expect(existsSync(join(__dirname, '/dist/app.bundle.js'))).toBeTruthy(); | ||
expect(existsSync(join(__dirname, '/dist/print.bundle.js'))).toBeTruthy(); | ||
// index fallback should not be used even when the file is present | ||
expect(existsSync(join(__dirname, '/dist/index.bundle.js'))).toBeFalsy(); | ||
expect(stderr).toBeFalsy(); | ||
}); | ||
}); |
This file contains 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('app'); |
This file contains 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('index') |
This file contains 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('print'); |
13 changes: 13 additions & 0 deletions
13
test/entry/config-entry/entry-with-index/webpack.config.js
This file contains 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,13 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
mode: 'development', | ||
entry: { | ||
app: './src/app.js', | ||
print: './src/print.js', | ||
}, | ||
output: { | ||
filename: '[name].bundle.js', | ||
path: path.resolve(__dirname, 'dist'), | ||
}, | ||
}; |