Skip to content

Commit 4110f6e

Browse files
committed
test: add tests for configureDevServerOptions
1 parent 3fe3ab9 commit 4110f6e

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/config-generator.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,31 @@ describe('The config-generator function', () => {
588588
expect(actualConfig.devServer.hot).to.be.true;
589589
});
590590

591+
it('devServer with custom options', () => {
592+
const config = createConfig();
593+
config.runtimeConfig.useDevServer = true;
594+
config.runtimeConfig.devServerUrl = 'http://localhost:8080/';
595+
config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public';
596+
config.setPublicPath('/');
597+
config.addEntry('main', './main');
598+
599+
config.configureDevServerOptions(options => {
600+
options.https = {
601+
key: 'https.key',
602+
cert: 'https.cert',
603+
};
604+
});
605+
606+
const actualConfig = configGenerator(config);
607+
608+
expect(actualConfig.devServer).to.containSubset({
609+
https: {
610+
key: 'https.key',
611+
cert: 'https.cert',
612+
},
613+
});
614+
});
615+
591616
it('devServer with custom watch options', () => {
592617
const config = createConfig();
593618
config.runtimeConfig.useDevServer = true;
@@ -602,6 +627,7 @@ describe('The config-generator function', () => {
602627
});
603628

604629
const actualConfig = configGenerator(config);
630+
605631
expect(actualConfig.watchOptions).to.deep.equals({
606632
'ignored': /node_modules/,
607633
'poll': 250,
@@ -611,6 +637,34 @@ describe('The config-generator function', () => {
611637
'poll': 250,
612638
});
613639
});
640+
641+
it('devServer with custom options and watch options', () => {
642+
const config = createConfig();
643+
config.runtimeConfig.useDevServer = true;
644+
config.runtimeConfig.devServerUrl = 'http://localhost:8080/';
645+
config.runtimeConfig.useHotModuleReplacement = true;
646+
config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public';
647+
config.setPublicPath('/');
648+
config.addEntry('main', './main');
649+
650+
config.configureWatchOptions(watchOptions => {
651+
watchOptions.poll = 250;
652+
});
653+
config.configureDevServerOptions(options => {
654+
// should take precedence over `configureWatchOptions()`
655+
options.watchOptions.poll = 500;
656+
});
657+
658+
const actualConfig = configGenerator(config);
659+
expect(actualConfig.watchOptions).to.deep.equals({
660+
'ignored': /node_modules/,
661+
'poll': 250,
662+
});
663+
expect(actualConfig.devServer.watchOptions).to.deep.equals({
664+
'ignored': /node_modules/,
665+
'poll': 500,
666+
});
667+
});
614668
});
615669

616670
describe('test for addPlugin config', () => {

0 commit comments

Comments
 (0)