Skip to content

Commit 4d5307b

Browse files
committed
test: updates
1 parent 11700c5 commit 4d5307b

31 files changed

+1358
-1174
lines changed

lib/options.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@
212212
"type": "string",
213213
"description": "Tells clients connected to devServer to use the provided host."
214214
},
215-
"path": {
216-
"type": "string",
217-
"description": "Tells clients connected to devServer to use the provided path to connect."
218-
},
219215
"port": {
220216
"anyOf": [
221217
{
@@ -232,7 +228,7 @@
232228
},
233229
"path": {
234230
"type": "string",
235-
"description": "Tells clients connected to devServer to use the provided port."
231+
"description": "Tells clients connected to devServer to use the provided path to connect."
236232
},
237233
"logging": {
238234
"enum": ["none", "error", "warn", "info", "log", "verbose"],

lib/servers/WebsocketServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = class WebsocketServer extends BaseServer {
1010
constructor(server) {
1111
super(server);
1212

13-
this.wsServer = new ws.Server({
13+
this.webSocketServer = new ws.Server({
1414
...this.server.options.webSocketServer.options,
1515
noServer: true,
1616
});

test/__snapshots__/validate-options.test.js.snap.webpack4

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,28 @@ exports[`options validate should throw an error on the "client" option with '{"p
9696
-> Print compilation progress in percentage in the browser."
9797
`;
9898

99+
exports[`options validate should throw an error on the "client" option with '{"transport":true}' value 1`] = `
100+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
101+
- configuration.client.transport should be one of these:
102+
\\"sockjs\\" | \\"ws\\" | non-empty string
103+
-> Allows to set custom transport to communicate with server.
104+
Details:
105+
* configuration.client.transport should be one of these:
106+
\\"sockjs\\" | \\"ws\\"
107+
* configuration.client.transport should be a non-empty string."
108+
`;
109+
99110
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
100111
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
101112
- configuration.client has an unknown property 'unknownOption'. These properties are valid:
102-
object { host?, path?, port?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
113+
object { transport?, host?, port?, path?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
103114
-> Specifies client properties. https://webpack.js.org/configuration/dev-server/#devserverclient"
104115
`;
105116

106117
exports[`options validate should throw an error on the "client" option with 'whoops!' value 1`] = `
107118
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
108119
- configuration.client should be an object:
109-
object { host?, path?, port?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
120+
object { transport?, host?, port?, path?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
110121
-> Specifies client properties. https://webpack.js.org/configuration/dev-server/#devserverclient"
111122
`;
112123

@@ -489,54 +500,6 @@ exports[`options validate should throw an error on the "static" option with 'nul
489500
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)"
490501
`;
491502

492-
exports[`options validate should throw an error on the "transportMode" option with '{"notAnOption":true}' value 1`] = `
493-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
494-
- configuration.transportMode has an unknown property 'notAnOption'. These properties are valid:
495-
object { client?, server? }"
496-
`;
497-
498-
exports[`options validate should throw an error on the "transportMode" option with '{"server":false}' value 1`] = `
499-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
500-
- configuration.transportMode should be one of these:
501-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
502-
-> This option allows us either to choose the current devServer transport mode for client/server individually or to provide custom client/server implementation. https://webpack.js.org/configuration/dev-server/#devservertransportmode
503-
Details:
504-
* configuration.transportMode.server should be one of these:
505-
string | function
506-
Details:
507-
* configuration.transportMode.server should be a string.
508-
* configuration.transportMode.server should be an instance of function."
509-
`;
510-
511-
exports[`options validate should throw an error on the "transportMode" option with '{}' value 1`] = `
512-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
513-
- configuration.transportMode.client should be a string."
514-
`;
515-
516-
exports[`options validate should throw an error on the "transportMode" option with 'nonexistent-implementation' value 1`] = `
517-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
518-
- configuration.transportMode should be one of these:
519-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
520-
-> This option allows us either to choose the current devServer transport mode for client/server individually or to provide custom client/server implementation. https://webpack.js.org/configuration/dev-server/#devservertransportmode
521-
Details:
522-
* configuration.transportMode should be an object:
523-
object { client?, server? }
524-
* configuration.transportMode should be one of these:
525-
\\"sockjs\\" | \\"ws\\""
526-
`;
527-
528-
exports[`options validate should throw an error on the "transportMode" option with 'null' value 1`] = `
529-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
530-
- configuration.transportMode should be one of these:
531-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
532-
-> This option allows us either to choose the current devServer transport mode for client/server individually or to provide custom client/server implementation. https://webpack.js.org/configuration/dev-server/#devservertransportmode
533-
Details:
534-
* configuration.transportMode should be an object:
535-
object { client?, server? }
536-
* configuration.transportMode should be one of these:
537-
\\"sockjs\\" | \\"ws\\""
538-
`;
539-
540503
exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
541504
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
542505
- configuration.watchFiles should be one of these:
@@ -562,3 +525,54 @@ exports[`options validate should throw an error on the "watchFiles" option with
562525
* configuration.watchFiles should be an array:
563526
[non-empty string | object { paths?, options? }, ...]"
564527
`;
528+
529+
exports[`options validate should throw an error on the "webSocketServer" option with '{"notAnOption":true}' value 1`] = `
530+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
531+
- configuration.webSocketServer has an unknown property 'notAnOption'. These properties are valid:
532+
object { type?, options? }"
533+
`;
534+
535+
exports[`options validate should throw an error on the "webSocketServer" option with '{"type":true}' value 1`] = `
536+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
537+
- configuration.webSocketServer should be one of these:
538+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
539+
-> Allows to set web socket server and options.
540+
Details:
541+
* configuration.webSocketServer.type should be one of these:
542+
\\"sockjs\\" | \\"ws\\" | non-empty string | function
543+
Details:
544+
* configuration.webSocketServer.type should be one of these:
545+
\\"sockjs\\" | \\"ws\\"
546+
* configuration.webSocketServer.type should be a non-empty string.
547+
* configuration.webSocketServer.type should be an instance of function."
548+
`;
549+
550+
exports[`options validate should throw an error on the "webSocketServer" option with 'false' value 1`] = `
551+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
552+
- configuration.webSocketServer should be one of these:
553+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
554+
-> Allows to set web socket server and options.
555+
Details:
556+
* configuration.webSocketServer should be one of these:
557+
\\"sockjs\\" | \\"ws\\"
558+
* configuration.webSocketServer should be a non-empty string.
559+
* configuration.webSocketServer should be an instance of function.
560+
* configuration.webSocketServer should be an object:
561+
object { type?, options? }"
562+
`;
563+
564+
exports[`options validate should throw an error on the "webSocketServer" option with 'nonexistent-implementation' value 1`] = `"Error: client.transport must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to a JS file which exports a class extending BaseClient (webpack-dev-server/client-src/clients/BaseClient.js) via require.resolve(...)"`;
565+
566+
exports[`options validate should throw an error on the "webSocketServer" option with 'null' value 1`] = `
567+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
568+
- configuration.webSocketServer should be one of these:
569+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
570+
-> Allows to set web socket server and options.
571+
Details:
572+
* configuration.webSocketServer should be one of these:
573+
\\"sockjs\\" | \\"ws\\"
574+
* configuration.webSocketServer should be a non-empty string.
575+
* configuration.webSocketServer should be an instance of function.
576+
* configuration.webSocketServer should be an object:
577+
object { type?, options? }"
578+
`;

test/__snapshots__/validate-options.test.js.snap.webpack5

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,28 @@ exports[`options validate should throw an error on the "client" option with '{"p
9696
-> Print compilation progress in percentage in the browser."
9797
`;
9898

99+
exports[`options validate should throw an error on the "client" option with '{"transport":true}' value 1`] = `
100+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
101+
- configuration.client.transport should be one of these:
102+
\\"sockjs\\" | \\"ws\\" | non-empty string
103+
-> Allows to set custom transport to communicate with server.
104+
Details:
105+
* configuration.client.transport should be one of these:
106+
\\"sockjs\\" | \\"ws\\"
107+
* configuration.client.transport should be a non-empty string."
108+
`;
109+
99110
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
100111
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
101112
- configuration.client has an unknown property 'unknownOption'. These properties are valid:
102-
object { host?, path?, port?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
113+
object { transport?, host?, port?, path?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
103114
-> Specifies client properties. https://webpack.js.org/configuration/dev-server/#devserverclient"
104115
`;
105116

106117
exports[`options validate should throw an error on the "client" option with 'whoops!' value 1`] = `
107118
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
108119
- configuration.client should be an object:
109-
object { host?, path?, port?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
120+
object { transport?, host?, port?, path?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
110121
-> Specifies client properties. https://webpack.js.org/configuration/dev-server/#devserverclient"
111122
`;
112123

@@ -489,54 +500,6 @@ exports[`options validate should throw an error on the "static" option with 'nul
489500
[non-empty string | object { directory?, staticOptions?, publicPath?, serveIndex?, watch? }, ...] (should not have fewer than 1 item)"
490501
`;
491502

492-
exports[`options validate should throw an error on the "transportMode" option with '{"notAnOption":true}' value 1`] = `
493-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
494-
- configuration.transportMode has an unknown property 'notAnOption'. These properties are valid:
495-
object { client?, server? }"
496-
`;
497-
498-
exports[`options validate should throw an error on the "transportMode" option with '{"server":false}' value 1`] = `
499-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
500-
- configuration.transportMode should be one of these:
501-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
502-
-> This option allows us either to choose the current devServer transport mode for client/server individually or to provide custom client/server implementation. https://webpack.js.org/configuration/dev-server/#devservertransportmode
503-
Details:
504-
* configuration.transportMode.server should be one of these:
505-
string | function
506-
Details:
507-
* configuration.transportMode.server should be a string.
508-
* configuration.transportMode.server should be an instance of function."
509-
`;
510-
511-
exports[`options validate should throw an error on the "transportMode" option with '{}' value 1`] = `
512-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
513-
- configuration.transportMode.client should be a string."
514-
`;
515-
516-
exports[`options validate should throw an error on the "transportMode" option with 'nonexistent-implementation' value 1`] = `
517-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
518-
- configuration.transportMode should be one of these:
519-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
520-
-> This option allows us either to choose the current devServer transport mode for client/server individually or to provide custom client/server implementation. https://webpack.js.org/configuration/dev-server/#devservertransportmode
521-
Details:
522-
* configuration.transportMode should be an object:
523-
object { client?, server? }
524-
* configuration.transportMode should be one of these:
525-
\\"sockjs\\" | \\"ws\\""
526-
`;
527-
528-
exports[`options validate should throw an error on the "transportMode" option with 'null' value 1`] = `
529-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
530-
- configuration.transportMode should be one of these:
531-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
532-
-> This option allows us either to choose the current devServer transport mode for client/server individually or to provide custom client/server implementation. https://webpack.js.org/configuration/dev-server/#devservertransportmode
533-
Details:
534-
* configuration.transportMode should be an object:
535-
object { client?, server? }
536-
* configuration.transportMode should be one of these:
537-
\\"sockjs\\" | \\"ws\\""
538-
`;
539-
540503
exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
541504
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
542505
- configuration.watchFiles should be one of these:
@@ -562,3 +525,54 @@ exports[`options validate should throw an error on the "watchFiles" option with
562525
* configuration.watchFiles should be an array:
563526
[non-empty string | object { paths?, options? }, ...]"
564527
`;
528+
529+
exports[`options validate should throw an error on the "webSocketServer" option with '{"notAnOption":true}' value 1`] = `
530+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
531+
- configuration.webSocketServer has an unknown property 'notAnOption'. These properties are valid:
532+
object { type?, options? }"
533+
`;
534+
535+
exports[`options validate should throw an error on the "webSocketServer" option with '{"type":true}' value 1`] = `
536+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
537+
- configuration.webSocketServer should be one of these:
538+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
539+
-> Allows to set web socket server and options.
540+
Details:
541+
* configuration.webSocketServer.type should be one of these:
542+
\\"sockjs\\" | \\"ws\\" | non-empty string | function
543+
Details:
544+
* configuration.webSocketServer.type should be one of these:
545+
\\"sockjs\\" | \\"ws\\"
546+
* configuration.webSocketServer.type should be a non-empty string.
547+
* configuration.webSocketServer.type should be an instance of function."
548+
`;
549+
550+
exports[`options validate should throw an error on the "webSocketServer" option with 'false' value 1`] = `
551+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
552+
- configuration.webSocketServer should be one of these:
553+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
554+
-> Allows to set web socket server and options.
555+
Details:
556+
* configuration.webSocketServer should be one of these:
557+
\\"sockjs\\" | \\"ws\\"
558+
* configuration.webSocketServer should be a non-empty string.
559+
* configuration.webSocketServer should be an instance of function.
560+
* configuration.webSocketServer should be an object:
561+
object { type?, options? }"
562+
`;
563+
564+
exports[`options validate should throw an error on the "webSocketServer" option with 'nonexistent-implementation' value 1`] = `"Error: client.transport must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to a JS file which exports a class extending BaseClient (webpack-dev-server/client-src/clients/BaseClient.js) via require.resolve(...)"`;
565+
566+
exports[`options validate should throw an error on the "webSocketServer" option with 'null' value 1`] = `
567+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
568+
- configuration.webSocketServer should be one of these:
569+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
570+
-> Allows to set web socket server and options.
571+
Details:
572+
* configuration.webSocketServer should be one of these:
573+
\\"sockjs\\" | \\"ws\\"
574+
* configuration.webSocketServer should be a non-empty string.
575+
* configuration.webSocketServer should be an instance of function.
576+
* configuration.webSocketServer should be an object:
577+
object { type?, options? }"
578+
`;

test/e2e/ProvidePlugin.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const port = require('../ports-map').ProvidePlugin;
88
const { beforeBrowserCloseDelay } = require('../helpers/puppeteer-constants');
99

1010
describe('ProvidePlugin', () => {
11-
describe('default transportMode.client (ws)', () => {
11+
describe('default client.transport (ws)', () => {
1212
beforeAll((done) => {
1313
const options = {
1414
port,
@@ -40,12 +40,14 @@ describe('ProvidePlugin', () => {
4040
});
4141
});
4242

43-
describe('with transportMode.client sockjs', () => {
43+
describe('with client.transport sockjs', () => {
4444
beforeAll((done) => {
4545
const options = {
4646
port,
4747
host: '0.0.0.0',
48-
transportMode: 'sockjs',
48+
client: {
49+
transport: 'sockjs',
50+
},
4951
};
5052
testServer.startAwaitingCompilation(sockjsConfig, options, done);
5153
});

0 commit comments

Comments
 (0)