Skip to content
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

test(dev-sever): add e2e test cases part 3 #7833

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ tests/plugin-test/css-extract/js

tests/plugin-test/html-plugin/js

!packages/rspack-dev-server/tests/fixtures/**/node_modules

/webpack-examples/**/dist

smoke-example
Expand Down
20 changes: 11 additions & 9 deletions packages/rspack-dev-server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ const config = {
testPathIgnorePatterns: isWin
? []
: [
// TODO: check why http proxy server throw error with websocket server
"<rootDir>/tests/e2e/allowed-hosts.test.js",
// TODO: check why this test timeout
"<rootDir>/tests/e2e/host.test.js",
// TODO: not support progress plugin event yet
"<rootDir>/tests/e2e/progress.test.js",
// TODO: check why this test throw error when run with other tests
"<rootDir>/tests/e2e/watch-files.test.js"
],
// TODO: check why http proxy server throw error with websocket server
"<rootDir>/tests/e2e/allowed-hosts.test.js",
// TODO: check why this test timeout
"<rootDir>/tests/e2e/host.test.js",
// TODO: not support progress plugin event yet
"<rootDir>/tests/e2e/progress.test.js",
// TODO: check why this test throw error when run with other tests
"<rootDir>/tests/e2e/watch-files.test.js",
// TODO: check why this test timeout
"<rootDir>/tests/e2e/web-socket-server-url.test.js"
],
cache: false,
testTimeout: process.env.CI ? 120000 : 30000,
transform: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`port should work using "<not-specified>" port : console messages 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
"Hey.",
]
`;

exports[`port should work using "<not-specified>" port : page errors 1`] = `[]`;

exports[`port should work using "0" port : console messages 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
"Hey.",
]
`;

exports[`port should work using "0" port : page errors 1`] = `[]`;

exports[`port should work using "8161" port : console messages 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
"Hey.",
]
`;

exports[`port should work using "8161" port : console messages 2`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
"Hey.",
]
`;

exports[`port should work using "8161" port : page errors 1`] = `[]`;

exports[`port should work using "8161" port : page errors 2`] = `[]`;

exports[`port should work using "auto" port : console messages 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
"Hey.",
]
`;

exports[`port should work using "auto" port : page errors 1`] = `[]`;

exports[`port should work using "undefined" port : console messages 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
"Hey.",
]
`;

exports[`port should work using "undefined" port : page errors 1`] = `[]`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`server and client transport should throw an error on invalid path to client transport 1`] = `"client.webSocketTransport must be a string denoting a default implementation (e.g. 'sockjs', 'ws') or a full path to a JS file via require.resolve(...) which exports a class "`;

exports[`server and client transport should throw an error on invalid path to server transport 1`] = `"webSocketServer (webSocketServer.type) must be a string denoting a default implementation (e.g. 'ws', 'sockjs'), a full path to a JS file which exports a class extending BaseServer (webpack-dev-server/lib/servers/BaseServer.js) via require.resolve(...), or the class itself which extends BaseServer"`;

exports[`server and client transport should throw an error on wrong path 1`] = `"webSocketServer (webSocketServer.type) must be a string denoting a default implementation (e.g. 'ws', 'sockjs'), a full path to a JS file which exports a class extending BaseServer (webpack-dev-server/lib/servers/BaseServer.js) via require.resolve(...), or the class itself which extends BaseServer"`;

exports[`server and client transport should use "sockjs" transport and "sockjs" web socket server 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use "sockjs" transport, when web socket server is not specify 1`] = `[]`;

exports[`server and client transport should use "sockjs" web socket server when specify "sockjs" value 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use "sockjs" web socket server when specify "sockjs" value using object 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use "ws" transport and "ws" web socket server 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use "ws" transport, when web socket server is not specify 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use "ws" web socket server when specify "ws" value 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use "ws" web socket server when specify "ws" value using object 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use custom transport and "sockjs" web socket server 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
"open",
"hot",
"liveReload",
"reconnect",
"overlay",
"hash",
"ok",
]
`;

exports[`server and client transport should use custom web socket server when specify class 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use custom web socket server when specify class using object 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use custom web socket server when specify path to class 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use custom web socket server when specify path to class using object 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;

exports[`server and client transport should use default web socket server ("ws") 1`] = `
[
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
"[HMR] Waiting for update signal from WDS...",
]
`;
Loading
Loading