Skip to content

Commit

Permalink
fix: add description for watchFiles options (#4057)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Nov 26, 2021
1 parent c5b9c7e commit 75f3817
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -984,10 +984,13 @@
"type": "string",
"minLength": 1
}
]
],
"description": "Path(s) of globs/directories/files to watch for file changes."
},
"options": {
"type": "object",
"description": "Configure advanced options for watching. See the chokidar documentation for the possible options.",
"link": "https://github.com/paulmillr/chokidar#api",
"additionalProperties": true
}
},
Expand Down
24 changes: 24 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,30 @@ exports[`options validate should throw an error on the "static" option with 'nul
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
`;

exports[`options validate should throw an error on the "watchFiles" option with '{"options":false}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.watchFiles.options should be an object:
object { … }
-> Configure advanced options for watching. See the chokidar documentation for the possible options.
-> Read more at https://github.com/paulmillr/chokidar#api"
`;

exports[`options validate should throw an error on the "watchFiles" option with '{"paths":false}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.watchFiles should be one of these:
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
-> Allows to configure list of globs/directories/files to watch for file changes.
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
Details:
* options.watchFiles.paths should be one of these:
[non-empty string, ...] | non-empty string
-> Path(s) of globs/directories/files to watch for file changes.
Details:
* options.watchFiles.paths should be an array:
[non-empty string, ...]
* options.watchFiles.paths should be a non-empty string."
`;

exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.watchFiles should be one of these:
Expand Down
24 changes: 24 additions & 0 deletions test/__snapshots__/validate-options.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,30 @@ exports[`options validate should throw an error on the "static" option with 'nul
object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }"
`;

exports[`options validate should throw an error on the "watchFiles" option with '{"options":false}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.watchFiles.options should be an object:
object { … }
-> Configure advanced options for watching. See the chokidar documentation for the possible options.
-> Read more at https://github.com/paulmillr/chokidar#api"
`;

exports[`options validate should throw an error on the "watchFiles" option with '{"paths":false}' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.watchFiles should be one of these:
[non-empty string | object { paths?, options? }, ...] | non-empty string | object { paths?, options? }
-> Allows to configure list of globs/directories/files to watch for file changes.
-> Read more at https://webpack.js.org/configuration/dev-server/#devserverwatchfiles
Details:
* options.watchFiles.paths should be one of these:
[non-empty string, ...] | non-empty string
-> Path(s) of globs/directories/files to watch for file changes.
Details:
* options.watchFiles.paths should be an array:
[non-empty string, ...]
* options.watchFiles.paths should be a non-empty string."
`;

exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options.watchFiles should be one of these:
Expand Down
11 changes: 10 additions & 1 deletion test/validate-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,16 @@ const tests = {
{ paths: ["dir"], options: { usePolling: true } },
[{ paths: ["one-dir"] }, "two-dir"],
],
failure: [false, 123],
failure: [
false,
123,
{
paths: false,
},
{
options: false,
},
],
},
};

Expand Down

0 comments on commit 75f3817

Please sign in to comment.