Skip to content

Commit 6751e5e

Browse files
committed
Add tests
1 parent dbe8d39 commit 6751e5e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

test/WebpackConfig.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,4 +1065,29 @@ describe('WebpackConfig object', () => {
10651065
}).to.throw('"foo" is not a valid key');
10661066
});
10671067
});
1068+
1069+
describe('configureDevServerWatchOptions()', () => {
1070+
it('Pass config', () => {
1071+
const config = createConfig();
1072+
const callback = (watchOptions) => {
1073+
watchOptions.poll = 250;
1074+
};
1075+
1076+
config.configureDevServerWatchOptions(callback);
1077+
1078+
expect(config.devServerWatchOptionsConfigurationCallback).to.equal(callback);
1079+
});
1080+
1081+
it('Call method without a valid callback', () => {
1082+
const config = createConfig();
1083+
1084+
expect(() => {
1085+
config.configureDevServerWatchOptions();
1086+
}).to.throw('Argument 1 to configureDevServerWatchOptions() must be a callback function.');
1087+
1088+
expect(() => {
1089+
config.configureDevServerWatchOptions({});
1090+
}).to.throw('Argument 1 to configureDevServerWatchOptions() must be a callback function.');
1091+
});
1092+
});
10681093
});

test/config-generator.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,26 @@ describe('The config-generator function', () => {
573573
const actualConfig = configGenerator(config);
574574
expect(actualConfig.devServer.hot).to.be.true;
575575
});
576+
577+
it('devServer with custom watch options', () => {
578+
const config = createConfig();
579+
config.runtimeConfig.useDevServer = true;
580+
config.runtimeConfig.devServerUrl = 'http://localhost:8080/';
581+
config.runtimeConfig.useHotModuleReplacement = true;
582+
config.outputPath = isWindows ? 'C:\\tmp\\public' : '/tmp/public';
583+
config.setPublicPath('/');
584+
config.addEntry('main', './main');
585+
586+
config.configureDevServerWatchOptions(watchOptions => {
587+
watchOptions.poll = 250;
588+
});
589+
590+
const actualConfig = configGenerator(config);
591+
expect(actualConfig.devServer.watchOptions).to.deep.equals({
592+
'ignored': /node_modules/,
593+
'poll': 250,
594+
});
595+
});
576596
});
577597

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

0 commit comments

Comments
 (0)