Skip to content

Commit 68e2f06

Browse files
authored
test: more cases for webSocketURL (#3423)
1 parent 5c87961 commit 68e2f06

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

test/e2e/web-socket-server-and-url.test.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,99 @@ for (const webSocketServerType of webSocketServerTypes) {
454454
});
455455
});
456456

457+
describe('should work when "port" option is "auto"', () => {
458+
beforeAll((done) => {
459+
const options = {
460+
webSocketServer: webSocketServerType,
461+
port: 'auto',
462+
host: '0.0.0.0',
463+
};
464+
testServer.startAwaitingCompilation(config, options, done);
465+
});
466+
467+
afterAll(testServer.close);
468+
469+
describe('browser client', () => {
470+
it('should work', (done) => {
471+
runBrowser().then(({ page, browser }) => {
472+
waitForTest(browser, page, /ws/, (websocketUrl) => {
473+
expect(websocketUrl).toContain(
474+
`${websocketUrlProtocol}://localhost:8080/ws`
475+
);
476+
477+
done();
478+
});
479+
480+
page.goto(`http://localhost:8080/main`);
481+
});
482+
});
483+
});
484+
});
485+
486+
describe('should work when "host" option is IPv4', () => {
487+
beforeAll((done) => {
488+
const options = {
489+
webSocketServer: webSocketServerType,
490+
port: port3,
491+
host: internalIp.v4.sync(),
492+
};
493+
testServer.startAwaitingCompilation(config, options, done);
494+
});
495+
496+
afterAll(testServer.close);
497+
498+
describe('browser client', () => {
499+
it('should work', (done) => {
500+
runBrowser().then(({ page, browser }) => {
501+
waitForTest(browser, page, /ws/, (websocketUrl) => {
502+
expect(websocketUrl).toContain(
503+
`${websocketUrlProtocol}://${internalIp.v4.sync()}:${port3}/ws`
504+
);
505+
506+
done();
507+
});
508+
509+
page.goto(`http://${internalIp.v4.sync()}:${port3}/main`);
510+
});
511+
});
512+
});
513+
});
514+
515+
describe('should work with the "client.webSocketURL.port" option is 0', () => {
516+
beforeAll((done) => {
517+
const options = {
518+
webSocketServer: webSocketServerType,
519+
port: port2,
520+
host: '0.0.0.0',
521+
client: {
522+
webSocketURL: {
523+
port: 0,
524+
},
525+
},
526+
};
527+
528+
testServer.startAwaitingCompilation(config, options, done);
529+
});
530+
531+
afterAll(testServer.close);
532+
533+
describe('browser client', () => {
534+
it('should work', (done) => {
535+
runBrowser().then(({ page, browser }) => {
536+
waitForTest(browser, page, /ws/, (websocketUrl) => {
537+
expect(websocketUrl).toContain(
538+
`${websocketUrlProtocol}://localhost:${port2}/ws`
539+
);
540+
541+
done();
542+
});
543+
544+
page.goto(`http://localhost:${port2}/main`);
545+
});
546+
});
547+
});
548+
});
549+
457550
describe('should work with "client.webSocketURL.port" and "client.webSocketURL.path" options', () => {
458551
beforeAll((done) => {
459552
const options = {

0 commit comments

Comments
 (0)