Skip to content

Commit

Permalink
tests: add tests for entry in config (#1718)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv authored Aug 1, 2020
1 parent 1249e1e commit 123f51e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
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'),
},
};

0 comments on commit 123f51e

Please sign in to comment.