Skip to content

Commit

Permalink
test: add validation test for liveReload option (#3718)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Aug 22, 2021
1 parent f563d1d commit 8a3f0d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions test/validate-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [""],
Expand Down

0 comments on commit 8a3f0d8

Please # to comment.