Skip to content

Commit

Permalink
tests: publicPath
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Dec 30, 2020
1 parent 0595603 commit 69a6feb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
13 changes: 13 additions & 0 deletions test/serve/basic/dev-server-output-public-path.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin');

module.exports = {
mode: 'development',
devtool: false,
output: {
publicPath: '/my-public-path/',
},
devServer: {
publicPath: '/dev-server-my-public-path/',
},
plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')],
};
10 changes: 10 additions & 0 deletions test/serve/basic/output-public-path.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const WebpackCLITestPlugin = require('../../utils/webpack-cli-test-plugin');

module.exports = {
mode: 'development',
devtool: false,
output: {
publicPath: '/my-public-path/',
},
plugins: [new WebpackCLITestPlugin(['mode', 'output'], false, 'hooks.compilation.taps')],
};
30 changes: 29 additions & 1 deletion test/serve/basic/serve-basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,35 @@ describe('basic serve usage', () => {
expect(stdout.match(/HotModuleReplacementPlugin/g)).toHaveLength(1);
});

it.only('should work with the "--open" option', async () => {
// TODO uncomment for webpack-dev-server@4
it.skip('should work with the "--output-public-path" option', async () => {
const { stderr, stdout } = await runServe(['serve', '--output-public-path', '/my-public-path/'], __dirname);

expect(stderr).toBeFalsy();
expect(stdout).toContain('main.js');
expect(stdout).toContain('/my-public-path/');
expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull();
});

it('should respect the "publicPath" option from configuration', async () => {
const { stderr, stdout } = await runServe(['serve', '--config', 'output-public-path.config.js'], __dirname);

expect(stderr).toBeFalsy();
expect(stdout).toContain('main.js');
expect(stdout).toContain('/my-public-path/');
expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull();
});

it('should respect the "publicPath" option from configuration (from the "devServer" options)', async () => {
const { stderr, stdout } = await runServe(['serve', '--config', 'dev-server-output-public-path.config.js'], __dirname);

expect(stderr).toBeFalsy();
expect(stdout).toContain('main.js');
expect(stdout).toContain('/dev-server-my-public-path/');
expect(stdout.match(/HotModuleReplacementPlugin/g)).toBeNull();
});

it('should work with the "--open" option', async () => {
const { stdout, stderr } = await runServe(['--open', '--port', port], testPath);

expect(stderr).toBeFalsy();
Expand Down

0 comments on commit 69a6feb

Please sign in to comment.