Skip to content
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

tests: add tests for entry in config #1718

Merged
merged 3 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions test/entry/config-entry/entry-with-index/entry-with-config.test.js
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();
});
});
1 change: 1 addition & 0 deletions test/entry/config-entry/entry-with-index/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('app');
1 change: 1 addition & 0 deletions test/entry/config-entry/entry-with-index/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('index')
1 change: 1 addition & 0 deletions test/entry/config-entry/entry-with-index/src/print.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('print');
13 changes: 13 additions & 0 deletions test/entry/config-entry/entry-with-index/webpack.config.js
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'),
},
};