Skip to content

test: more cases for webSocketURL #3423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions test/e2e/web-socket-server-and-url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,99 @@ for (const webSocketServerType of webSocketServerTypes) {
});
});

describe('should work when "port" option is "auto"', () => {
beforeAll((done) => {
const options = {
webSocketServer: webSocketServerType,
port: 'auto',
host: '0.0.0.0',
};
testServer.startAwaitingCompilation(config, options, done);
});

afterAll(testServer.close);

describe('browser client', () => {
it('should work', (done) => {
runBrowser().then(({ page, browser }) => {
waitForTest(browser, page, /ws/, (websocketUrl) => {
expect(websocketUrl).toContain(
`${websocketUrlProtocol}://localhost:8080/ws`
);

done();
});

page.goto(`http://localhost:8080/main`);
});
});
});
});

describe('should work when "host" option is IPv4', () => {
beforeAll((done) => {
const options = {
webSocketServer: webSocketServerType,
port: port3,
host: internalIp.v4.sync(),
};
testServer.startAwaitingCompilation(config, options, done);
});

afterAll(testServer.close);

describe('browser client', () => {
it('should work', (done) => {
runBrowser().then(({ page, browser }) => {
waitForTest(browser, page, /ws/, (websocketUrl) => {
expect(websocketUrl).toContain(
`${websocketUrlProtocol}://${internalIp.v4.sync()}:${port3}/ws`
);

done();
});

page.goto(`http://${internalIp.v4.sync()}:${port3}/main`);
});
});
});
});

describe('should work with the "client.webSocketURL.port" option is 0', () => {
beforeAll((done) => {
const options = {
webSocketServer: webSocketServerType,
port: port2,
host: '0.0.0.0',
client: {
webSocketURL: {
port: 0,
},
},
};

testServer.startAwaitingCompilation(config, options, done);
});

afterAll(testServer.close);

describe('browser client', () => {
it('should work', (done) => {
runBrowser().then(({ page, browser }) => {
waitForTest(browser, page, /ws/, (websocketUrl) => {
expect(websocketUrl).toContain(
`${websocketUrlProtocol}://localhost:${port2}/ws`
);

done();
});

page.goto(`http://localhost:${port2}/main`);
});
});
});
});

describe('should work with "client.webSocketURL.port" and "client.webSocketURL.path" options', () => {
beforeAll((done) => {
const options = {
Expand Down