From 8a3f0d8b9d41a4f431ceb4700341ac9e6e585563 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 22 Aug 2021 13:51:08 +0530 Subject: [PATCH] test: add validation test for `liveReload` option (#3718) --- test/__snapshots__/validate-options.test.js.snap.webpack4 | 7 +++++++ test/__snapshots__/validate-options.test.js.snap.webpack5 | 7 +++++++ test/validate-options.test.js | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 5a1b1dd914..77fc6bc030 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -432,6 +432,13 @@ exports[`options validate should throw an error on the "ipc" option with 'false' * options.ipc should be true." `; +exports[`options validate should throw an error on the "liveReload" option with 'invalid' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.liveReload should be a boolean. + -> Enables reload/refresh the page(s) when file changes are detected (enabled by default). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverlivereload" +`; + exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.onAfterSetupMiddleware should be an instance of function. diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 5a1b1dd914..77fc6bc030 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -432,6 +432,13 @@ exports[`options validate should throw an error on the "ipc" option with 'false' * options.ipc should be true." `; +exports[`options validate should throw an error on the "liveReload" option with 'invalid' value 1`] = ` +"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. + - options.liveReload should be a boolean. + -> Enables reload/refresh the page(s) when file changes are detected (enabled by default). + -> Read more at https://webpack.js.org/configuration/dev-server/#devserverlivereload" +`; + exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = ` "ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.onAfterSetupMiddleware should be an instance of function. diff --git a/test/validate-options.test.js b/test/validate-options.test.js index d984d48b52..af6f513b26 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -237,6 +237,10 @@ const tests = { success: [true, path.resolve(os.tmpdir(), "webpack-dev-server.socket")], failure: [false, {}], }, + liveReload: { + success: [true, false], + failure: ["invalid"], + }, onListening: { success: [() => {}], failure: [""],