Skip to content

Commit e08f597

Browse files
committed
test: updates
1 parent df8e93d commit e08f597

28 files changed

+1647
-1297
lines changed

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
@@ -79,17 +79,28 @@ exports[`options validate should throw an error on the "client" option with '{"p
7979
-> Print compilation progress in percentage in the browser."
8080
`;
8181

82+
exports[`options validate should throw an error on the "client" option with '{"transport":true}' value 1`] = `
83+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
84+
- configuration.client.transport should be one of these:
85+
\\"sockjs\\" | \\"ws\\" | non-empty string
86+
-> Allows to set custom transport to communicate with server.
87+
Details:
88+
* configuration.client.transport should be one of these:
89+
\\"sockjs\\" | \\"ws\\"
90+
* configuration.client.transport should be a non-empty string."
91+
`;
92+
8293
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
8394
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
8495
- configuration.client has an unknown property 'unknownOption'. These properties are valid:
85-
object { host?, path?, port?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
96+
object { transport?, host?, port?, path?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
8697
-> Specifies client properties. https://webpack.js.org/configuration/dev-server/#devserverclient"
8798
`;
8899

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

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

475-
exports[`options validate should throw an error on the "transportMode" option with '{"notAnOption":true}' value 1`] = `
476-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
477-
- configuration.transportMode has an unknown property 'notAnOption'. These properties are valid:
478-
object { client?, server? }"
479-
`;
480-
481-
exports[`options validate should throw an error on the "transportMode" option with '{"server":false}' value 1`] = `
482-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
483-
- configuration.transportMode should be one of these:
484-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
485-
-> 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
486-
Details:
487-
* configuration.transportMode.server should be one of these:
488-
string | function
489-
Details:
490-
* configuration.transportMode.server should be a string.
491-
* configuration.transportMode.server should be an instance of function."
492-
`;
493-
494-
exports[`options validate should throw an error on the "transportMode" option with '{}' value 1`] = `
495-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
496-
- configuration.transportMode.client should be a string."
497-
`;
498-
499-
exports[`options validate should throw an error on the "transportMode" option with 'nonexistent-implementation' value 1`] = `
500-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
501-
- configuration.transportMode should be one of these:
502-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
503-
-> 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
504-
Details:
505-
* configuration.transportMode should be an object:
506-
object { client?, server? }
507-
* configuration.transportMode should be one of these:
508-
\\"sockjs\\" | \\"ws\\""
509-
`;
510-
511-
exports[`options validate should throw an error on the "transportMode" option with 'null' 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 should be one of these:
514-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
515-
-> 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
516-
Details:
517-
* configuration.transportMode should be an object:
518-
object { client?, server? }
519-
* configuration.transportMode should be one of these:
520-
\\"sockjs\\" | \\"ws\\""
521-
`;
522-
523486
exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
524487
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
525488
- configuration.watchFiles should be one of these:
@@ -545,3 +508,54 @@ exports[`options validate should throw an error on the "watchFiles" option with
545508
* configuration.watchFiles should be an array:
546509
[non-empty string | object { paths?, options? }, ...]"
547510
`;
511+
512+
exports[`options validate should throw an error on the "webSocketServer" option with '{"notAnOption":true}' value 1`] = `
513+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
514+
- configuration.webSocketServer has an unknown property 'notAnOption'. These properties are valid:
515+
object { type?, options? }"
516+
`;
517+
518+
exports[`options validate should throw an error on the "webSocketServer" option with '{"type":true}' value 1`] = `
519+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
520+
- configuration.webSocketServer should be one of these:
521+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
522+
-> Allows to set web socket server and options.
523+
Details:
524+
* configuration.webSocketServer.type should be one of these:
525+
\\"sockjs\\" | \\"ws\\" | non-empty string | function
526+
Details:
527+
* configuration.webSocketServer.type should be one of these:
528+
\\"sockjs\\" | \\"ws\\"
529+
* configuration.webSocketServer.type should be a non-empty string.
530+
* configuration.webSocketServer.type should be an instance of function."
531+
`;
532+
533+
exports[`options validate should throw an error on the "webSocketServer" option with 'false' value 1`] = `
534+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
535+
- configuration.webSocketServer should be one of these:
536+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
537+
-> Allows to set web socket server and options.
538+
Details:
539+
* configuration.webSocketServer should be one of these:
540+
\\"sockjs\\" | \\"ws\\"
541+
* configuration.webSocketServer should be a non-empty string.
542+
* configuration.webSocketServer should be an instance of function.
543+
* configuration.webSocketServer should be an object:
544+
object { type?, options? }"
545+
`;
546+
547+
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(...)"`;
548+
549+
exports[`options validate should throw an error on the "webSocketServer" option with 'null' value 1`] = `
550+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
551+
- configuration.webSocketServer should be one of these:
552+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
553+
-> Allows to set web socket server and options.
554+
Details:
555+
* configuration.webSocketServer should be one of these:
556+
\\"sockjs\\" | \\"ws\\"
557+
* configuration.webSocketServer should be a non-empty string.
558+
* configuration.webSocketServer should be an instance of function.
559+
* configuration.webSocketServer should be an object:
560+
object { type?, options? }"
561+
`;

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

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

82+
exports[`options validate should throw an error on the "client" option with '{"transport":true}' value 1`] = `
83+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
84+
- configuration.client.transport should be one of these:
85+
\\"sockjs\\" | \\"ws\\" | non-empty string
86+
-> Allows to set custom transport to communicate with server.
87+
Details:
88+
* configuration.client.transport should be one of these:
89+
\\"sockjs\\" | \\"ws\\"
90+
* configuration.client.transport should be a non-empty string."
91+
`;
92+
8293
exports[`options validate should throw an error on the "client" option with '{"unknownOption":true}' value 1`] = `
8394
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
8495
- configuration.client has an unknown property 'unknownOption'. These properties are valid:
85-
object { host?, path?, port?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
96+
object { transport?, host?, port?, path?, logging?, progress?, overlay?, needClientEntry?, needHotEntry? }
8697
-> Specifies client properties. https://webpack.js.org/configuration/dev-server/#devserverclient"
8798
`;
8899

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

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

475-
exports[`options validate should throw an error on the "transportMode" option with '{"notAnOption":true}' value 1`] = `
476-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
477-
- configuration.transportMode has an unknown property 'notAnOption'. These properties are valid:
478-
object { client?, server? }"
479-
`;
480-
481-
exports[`options validate should throw an error on the "transportMode" option with '{"server":false}' value 1`] = `
482-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
483-
- configuration.transportMode should be one of these:
484-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
485-
-> 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
486-
Details:
487-
* configuration.transportMode.server should be one of these:
488-
string | function
489-
Details:
490-
* configuration.transportMode.server should be a string.
491-
* configuration.transportMode.server should be an instance of function."
492-
`;
493-
494-
exports[`options validate should throw an error on the "transportMode" option with '{}' value 1`] = `
495-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
496-
- configuration.transportMode.client should be a string."
497-
`;
498-
499-
exports[`options validate should throw an error on the "transportMode" option with 'nonexistent-implementation' value 1`] = `
500-
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
501-
- configuration.transportMode should be one of these:
502-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
503-
-> 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
504-
Details:
505-
* configuration.transportMode should be an object:
506-
object { client?, server? }
507-
* configuration.transportMode should be one of these:
508-
\\"sockjs\\" | \\"ws\\""
509-
`;
510-
511-
exports[`options validate should throw an error on the "transportMode" option with 'null' 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 should be one of these:
514-
object { client?, server? } | \\"sockjs\\" | \\"ws\\"
515-
-> 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
516-
Details:
517-
* configuration.transportMode should be an object:
518-
object { client?, server? }
519-
* configuration.transportMode should be one of these:
520-
\\"sockjs\\" | \\"ws\\""
521-
`;
522-
523486
exports[`options validate should throw an error on the "watchFiles" option with '123' value 1`] = `
524487
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
525488
- configuration.watchFiles should be one of these:
@@ -545,3 +508,54 @@ exports[`options validate should throw an error on the "watchFiles" option with
545508
* configuration.watchFiles should be an array:
546509
[non-empty string | object { paths?, options? }, ...]"
547510
`;
511+
512+
exports[`options validate should throw an error on the "webSocketServer" option with '{"notAnOption":true}' value 1`] = `
513+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
514+
- configuration.webSocketServer has an unknown property 'notAnOption'. These properties are valid:
515+
object { type?, options? }"
516+
`;
517+
518+
exports[`options validate should throw an error on the "webSocketServer" option with '{"type":true}' value 1`] = `
519+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
520+
- configuration.webSocketServer should be one of these:
521+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
522+
-> Allows to set web socket server and options.
523+
Details:
524+
* configuration.webSocketServer.type should be one of these:
525+
\\"sockjs\\" | \\"ws\\" | non-empty string | function
526+
Details:
527+
* configuration.webSocketServer.type should be one of these:
528+
\\"sockjs\\" | \\"ws\\"
529+
* configuration.webSocketServer.type should be a non-empty string.
530+
* configuration.webSocketServer.type should be an instance of function."
531+
`;
532+
533+
exports[`options validate should throw an error on the "webSocketServer" option with 'false' value 1`] = `
534+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
535+
- configuration.webSocketServer should be one of these:
536+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
537+
-> Allows to set web socket server and options.
538+
Details:
539+
* configuration.webSocketServer should be one of these:
540+
\\"sockjs\\" | \\"ws\\"
541+
* configuration.webSocketServer should be a non-empty string.
542+
* configuration.webSocketServer should be an instance of function.
543+
* configuration.webSocketServer should be an object:
544+
object { type?, options? }"
545+
`;
546+
547+
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(...)"`;
548+
549+
exports[`options validate should throw an error on the "webSocketServer" option with 'null' value 1`] = `
550+
"ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema.
551+
- configuration.webSocketServer should be one of these:
552+
\\"sockjs\\" | \\"ws\\" | non-empty string | function | object { type?, options? }
553+
-> Allows to set web socket server and options.
554+
Details:
555+
* configuration.webSocketServer should be one of these:
556+
\\"sockjs\\" | \\"ws\\"
557+
* configuration.webSocketServer should be a non-empty string.
558+
* configuration.webSocketServer should be an instance of function.
559+
* configuration.webSocketServer should be an object:
560+
object { type?, options? }"
561+
`;

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)