diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index edafcc5cf1c..27cb3dd6eab 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -73,7 +73,6 @@ pnpm-lock.yaml /packages/rspack /packages/rspack-cli /packages/rspack-dev-middleware -/packages/rspack-dev-server /packages/rspack-plugin-html /packages/rspack-plugin-minify /packages/rspack-plugin-node-polyfill diff --git a/.gitignore b/.gitignore index 9a4c6d416bd..78d24875a40 100644 --- a/.gitignore +++ b/.gitignore @@ -223,8 +223,6 @@ 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 diff --git a/biome.jsonc b/biome.jsonc index 6688f9c3bc9..0bd8dc56206 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -22,7 +22,6 @@ "packages/playground/**/*", // --- ignore runtime code in browser "packages/rspack/hot", - "packages/rspack-dev-server/client", "packages/rspack/src/container/default.runtime.js" ] }, @@ -65,8 +64,6 @@ "packages/rspack/module.d.ts", // --- ignore runtime code in browser "packages/rspack/hot", - "packages/rspack-dev-server/client", - "packages/rspack-dev-server/tests", "packages/rspack/src/container/default.runtime.js" ] }, @@ -76,4 +73,4 @@ "clientKind": "git", "useIgnoreFile": true } -} +} \ No newline at end of file diff --git a/packages/playground/package.json b/packages/playground/package.json index 7b59edfa1f1..285b36bcf05 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -17,7 +17,7 @@ "@playwright/test": "1.35.0", "core-js": "3.36.1", "@rspack/core": "workspace:*", - "@rspack/dev-server": "workspace:*", + "@rspack/dev-server": "1.0.6", "@rspack/plugin-react-refresh": "1.0.0", "@swc/helpers": "0.5.8", "@types/fs-extra": "11.0.4", diff --git a/packages/rspack-cli/package.json b/packages/rspack-cli/package.json index fd82cd6ad8f..3f8f61944e3 100644 --- a/packages/rspack-cli/package.json +++ b/packages/rspack-cli/package.json @@ -47,7 +47,7 @@ }, "dependencies": { "@discoveryjs/json-ext": "^0.5.7", - "@rspack/dev-server": "workspace:*", + "@rspack/dev-server": "1.0.6", "colorette": "2.0.19", "exit-hook": "^3.2.0", "interpret": "^3.1.1", diff --git a/packages/rspack-cli/tsconfig.build.json b/packages/rspack-cli/tsconfig.build.json index 6e792add4bb..418e8259150 100644 --- a/packages/rspack-cli/tsconfig.build.json +++ b/packages/rspack-cli/tsconfig.build.json @@ -7,9 +7,6 @@ "references": [ { "path": "../rspack/tsconfig.build.json" - }, - { - "path": "../rspack-dev-server/tsconfig.build.json" } ] -} +} \ No newline at end of file diff --git a/packages/rspack-cli/tsconfig.json b/packages/rspack-cli/tsconfig.json index e13412b8d19..9389c79517e 100644 --- a/packages/rspack-cli/tsconfig.json +++ b/packages/rspack-cli/tsconfig.json @@ -10,9 +10,6 @@ "references": [ { "path": "../rspack" - }, - { - "path": "../rspack-dev-server" } ] } \ No newline at end of file diff --git a/packages/rspack-dev-server/LICENSE b/packages/rspack-dev-server/LICENSE deleted file mode 100644 index 46310101ad8..00000000000 --- a/packages/rspack-dev-server/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2022-present Bytedance, Inc. and its affiliates. - - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/rspack-dev-server/README.md b/packages/rspack-dev-server/README.md deleted file mode 100644 index 6aa232c3e83..00000000000 --- a/packages/rspack-dev-server/README.md +++ /dev/null @@ -1,16 +0,0 @@ - - - Rspack Banner - - -# @rspack/dev-server - -Development server for rspack. - -## Documentation - -See [https://rspack.dev](https://rspack.dev) for details. - -## License - -Rspack is [MIT licensed](https://github.com/web-infra-dev/rspack/blob/main/LICENSE). diff --git a/packages/rspack-dev-server/api-extractor.json b/packages/rspack-dev-server/api-extractor.json deleted file mode 100644 index 1e0238cd9f0..00000000000 --- a/packages/rspack-dev-server/api-extractor.json +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Config file for API Extractor. For more info, please visit: https://api-extractor.com - */ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "extends": "../../api-extractor.json" -} diff --git a/packages/rspack-dev-server/client/index.js b/packages/rspack-dev-server/client/index.js deleted file mode 100644 index 87fa389986c..00000000000 --- a/packages/rspack-dev-server/client/index.js +++ /dev/null @@ -1,421 +0,0 @@ -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - enumerableOnly && - (symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - })), - keys.push.apply(keys, symbols); - } - return keys; -} -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = null != arguments[i] ? arguments[i] : {}; - i % 2 - ? ownKeys(Object(source), !0).forEach(function (key) { - _defineProperty(target, key, source[key]); - }) - : Object.getOwnPropertyDescriptors - ? Object.defineProperties( - target, - Object.getOwnPropertyDescriptors(source) - ) - : ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty( - target, - key, - Object.getOwnPropertyDescriptor(source, key) - ); - }); - } - return target; -} -function _defineProperty(obj, key, value) { - key = _toPropertyKey(key); - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - return obj; -} -function _toPropertyKey(arg) { - var key = _toPrimitive(arg, "string"); - return typeof key === "symbol" ? key : String(key); -} -function _toPrimitive(input, hint) { - if (typeof input !== "object" || input === null) return input; - var prim = input[Symbol.toPrimitive]; - if (prim !== undefined) { - var res = prim.call(input, hint || "default"); - if (typeof res !== "object") return res; - throw new TypeError("@@toPrimitive must return a primitive value."); - } - return (hint === "string" ? String : Number)(input); -} -/* global __resourceQuery, __webpack_hash__ */ -/// -import webpackHotLog from "@rspack/core/hot/log.js"; -import stripAnsi from "webpack-dev-server/client/utils/stripAnsi.js"; -import parseURL from "webpack-dev-server/client/utils/parseURL.js"; -import socket from "webpack-dev-server/client/socket.js"; -import { - formatProblem, - createOverlay -} from "webpack-dev-server/client/overlay.js"; -import { - log, - logEnabledFeatures, - setLogLevel -} from "webpack-dev-server/client/utils/log.js"; -import sendMessage from "webpack-dev-server/client/utils/sendMessage.js"; -import reloadApp from "./utils/reloadApp.js"; -import createSocketURL from "webpack-dev-server/client/utils/createSocketURL.js"; - -/** - * @typedef {Object} Options - * @property {boolean} hot - * @property {boolean} liveReload - * @property {boolean} progress - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean, trustedTypesPolicyName?: string }} overlay - * @property {string} [logging] - * @property {number} [reconnect] - */ - -/** - * @typedef {Object} Status - * @property {boolean} isUnloading - * @property {string} currentHash - * @property {string} [previousHash] - */ - -/** - * @type {Status} - */ -var status = { - isUnloading: false, - // TODO Workaround for webpack v4, `__webpack_hash__` is not replaced without HotModuleReplacement - // eslint-disable-next-line camelcase - currentHash: typeof __webpack_hash__ !== "undefined" ? __webpack_hash__ : "" -}; - -var decodeOverlayOptions = function decodeOverlayOptions(overlayOptions) { - if (typeof overlayOptions === "object") { - ["warnings", "errors", "runtimeErrors"].forEach(function (property) { - if (typeof overlayOptions[property] === "string") { - var overlayFilterFunctionString = decodeURIComponent( - overlayOptions[property] - ); - - // eslint-disable-next-line no-new-func - var overlayFilterFunction = new Function( - "message", - "var callback = ".concat( - overlayFilterFunctionString, - "\n return callback(message)" - ) - ); - overlayOptions[property] = overlayFilterFunction; - } - }); - } -}; - -/** @type {Options} */ -var options = { - hot: false, - liveReload: false, - progress: false, - overlay: false -}; -var parsedResourceQuery = parseURL(__resourceQuery); -var enabledFeatures = { - "Hot Module Replacement": false, - "Live Reloading": false, - Progress: false, - Overlay: false -}; -if (parsedResourceQuery.hot === "true") { - options.hot = true; - enabledFeatures["Hot Module Replacement"] = true; -} -if (parsedResourceQuery["live-reload"] === "true") { - options.liveReload = true; - enabledFeatures["Live Reloading"] = true; -} -if (parsedResourceQuery.progress === "true") { - options.progress = true; - enabledFeatures.Progress = true; -} - -if (parsedResourceQuery.overlay) { - try { - options.overlay = JSON.parse(parsedResourceQuery.overlay); - } catch (e) { - log.error("Error parsing overlay options from resource query:", e); - } - - // Fill in default "true" params for partially-specified objects. - if (typeof options.overlay === "object") { - options.overlay = _objectSpread( - { - errors: true, - warnings: true, - runtimeErrors: true - }, - options.overlay - ); - decodeOverlayOptions(options.overlay); - } - enabledFeatures.Overlay = true; -} -if (parsedResourceQuery.logging) { - options.logging = parsedResourceQuery.logging; -} -if (typeof parsedResourceQuery.reconnect !== "undefined") { - options.reconnect = Number(parsedResourceQuery.reconnect); -} - -/** - * @param {string} level - */ -function setAllLogLevel(level) { - // This is needed because the HMR logger operate separately from dev server logger - webpackHotLog.setLogLevel( - level === "verbose" || level === "log" ? "info" : level - ); - setLogLevel(level); -} -if (options.logging) { - setAllLogLevel(options.logging); -} -logEnabledFeatures(enabledFeatures); -self.addEventListener("beforeunload", function () { - status.isUnloading = true; -}); -var overlay = - typeof window !== "undefined" - ? createOverlay( - typeof options.overlay === "object" - ? { - trustedTypesPolicyName: options.overlay.trustedTypesPolicyName, - catchRuntimeError: options.overlay.runtimeErrors - } - : { - trustedTypesPolicyName: false, - catchRuntimeError: options.overlay - } - ) - : { - send: function send() {} - }; -var onSocketMessage = { - hot: function hot() { - if (parsedResourceQuery.hot === "false") { - return; - } - options.hot = true; - }, - liveReload: function liveReload() { - if (parsedResourceQuery["live-reload"] === "false") { - return; - } - options.liveReload = true; - }, - invalid: function invalid() { - log.info("App updated. Recompiling..."); - - // Fixes #1042. overlay doesn't clear if errors are fixed but warnings remain. - if (options.overlay) { - overlay.send({ - type: "DISMISS" - }); - } - sendMessage("Invalid"); - }, - /** - * @param {string} hash - */ - hash: function hash(_hash) { - status.previousHash = status.currentHash; - status.currentHash = _hash; - }, - logging: setAllLogLevel, - /** - * @param {boolean} value - */ - overlay: function overlay(value) { - if (typeof document === "undefined") { - return; - } - options.overlay = value; - decodeOverlayOptions(options.overlay); - }, - /** - * @param {number} value - */ - reconnect: function reconnect(value) { - if (parsedResourceQuery.reconnect === "false") { - return; - } - options.reconnect = value; - }, - /** - * @param {boolean} value - */ - progress: function progress(value) { - options.progress = value; - }, - /** - * @param {{ pluginName?: string, percent: number, msg: string }} data - */ - "progress-update": function progressUpdate(data) { - if (options.progress) { - log.info( - "" - .concat(data.pluginName ? "[".concat(data.pluginName, "] ") : "") - .concat(data.percent, "% - ") - .concat(data.msg, ".") - ); - } - sendMessage("Progress", data); - }, - "still-ok": function stillOk() { - log.info("Nothing changed."); - if (options.overlay) { - overlay.send({ - type: "DISMISS" - }); - } - sendMessage("StillOk"); - }, - ok: function ok() { - sendMessage("Ok"); - if (options.overlay) { - overlay.send({ - type: "DISMISS" - }); - } - reloadApp(options, status); - }, - // TODO: remove in v5 in favor of 'static-changed' - /** - * @param {string} file - */ - "content-changed": function contentChanged(file) { - log.info( - "".concat( - file ? '"'.concat(file, '"') : "Content", - " from static directory was changed. Reloading..." - ) - ); - self.location.reload(); - }, - /** - * @param {string} file - */ - "static-changed": function staticChanged(file) { - log.info( - "".concat( - file ? '"'.concat(file, '"') : "Content", - " from static directory was changed. Reloading..." - ) - ); - self.location.reload(); - }, - /** - * @param {Error[]} warnings - * @param {any} params - */ - warnings: function warnings(_warnings, params) { - log.warn("Warnings while compiling."); - var printableWarnings = _warnings.map(function (error) { - var _formatProblem = formatProblem("warning", error), - header = _formatProblem.header, - body = _formatProblem.body; - return "".concat(header, "\n").concat(stripAnsi(body)); - }); - sendMessage("Warnings", printableWarnings); - for (var i = 0; i < printableWarnings.length; i++) { - log.warn(printableWarnings[i]); - } - var overlayWarningsSetting = - typeof options.overlay === "boolean" - ? options.overlay - : options.overlay && options.overlay.warnings; - if (overlayWarningsSetting) { - var warningsToDisplay = - typeof overlayWarningsSetting === "function" - ? _warnings.filter(overlayWarningsSetting) - : _warnings; - if (warningsToDisplay.length) { - overlay.send({ - type: "BUILD_ERROR", - level: "warning", - messages: _warnings - }); - } - } - if (params && params.preventReloading) { - return; - } - reloadApp(options, status); - }, - /** - * @param {Error[]} errors - */ - errors: function errors(_errors) { - log.error("Errors while compiling. Reload prevented."); - var printableErrors = _errors.map(function (error) { - var _formatProblem2 = formatProblem("error", error), - header = _formatProblem2.header, - body = _formatProblem2.body; - return "".concat(header, "\n").concat(stripAnsi(body)); - }); - sendMessage("Errors", printableErrors); - for (var i = 0; i < printableErrors.length; i++) { - log.error(printableErrors[i]); - } - var overlayErrorsSettings = - typeof options.overlay === "boolean" - ? options.overlay - : options.overlay && options.overlay.errors; - if (overlayErrorsSettings) { - var errorsToDisplay = - typeof overlayErrorsSettings === "function" - ? _errors.filter(overlayErrorsSettings) - : _errors; - if (errorsToDisplay.length) { - overlay.send({ - type: "BUILD_ERROR", - level: "error", - messages: _errors - }); - } - } - }, - /** - * @param {Error} error - */ - error: function error(_error) { - log.error(_error); - }, - close: function close() { - log.info("Disconnected!"); - if (options.overlay) { - overlay.send({ - type: "DISMISS" - }); - } - sendMessage("Close"); - } -}; -var socketURL = createSocketURL(parsedResourceQuery); -socket(socketURL, onSocketMessage, options.reconnect); diff --git a/packages/rspack-dev-server/client/utils/reloadApp.js b/packages/rspack-dev-server/client/utils/reloadApp.js deleted file mode 100644 index 2c0fd85e8d9..00000000000 --- a/packages/rspack-dev-server/client/utils/reloadApp.js +++ /dev/null @@ -1,64 +0,0 @@ -import hotEmitter from "@rspack/core/hot/emitter.js"; -import { log } from "webpack-dev-server/client/utils/log.js"; - -/** @typedef {import("../index").Options} Options -/** @typedef {import("../index").Status} Status - -/** - * @param {Options} options - * @param {Status} status - */ -function reloadApp(_ref, status) { - var hot = _ref.hot, - liveReload = _ref.liveReload; - if (status.isUnloading) { - return; - } - var currentHash = status.currentHash, - previousHash = status.previousHash; - var isInitial = currentHash.indexOf(/** @type {string} */ previousHash) >= 0; - if (isInitial) { - return; - } - - /** - * @param {Window} rootWindow - * @param {number} intervalId - */ - function applyReload(rootWindow, intervalId) { - clearInterval(intervalId); - log.info("App updated. Reloading..."); - rootWindow.location.reload(); - } - var search = self.location.search.toLowerCase(); - var allowToHot = search.indexOf("webpack-dev-server-hot=false") === -1; - var allowToLiveReload = - search.indexOf("webpack-dev-server-live-reload=false") === -1; - if (hot && allowToHot) { - log.info("App hot update..."); - hotEmitter.emit("webpackHotUpdate", status.currentHash); - if (typeof self !== "undefined" && self.window) { - // broadcast update to window - self.postMessage("webpackHotUpdate".concat(status.currentHash), "*"); - } - } - // allow refreshing the page only if liveReload isn't disabled - else if (liveReload && allowToLiveReload) { - var rootWindow = self; - - // use parent window for reload (in case we're in an iframe with no valid src) - var intervalId = self.setInterval(function () { - if (rootWindow.location.protocol !== "about:") { - // reload immediately if protocol is valid - applyReload(rootWindow, intervalId); - } else { - rootWindow = rootWindow.parent; - if (rootWindow.parent === rootWindow) { - // if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways - applyReload(rootWindow, intervalId); - } - } - }); - } -} -export default reloadApp; diff --git a/packages/rspack-dev-server/etc/api.md b/packages/rspack-dev-server/etc/api.md deleted file mode 100644 index 1e29baba633..00000000000 --- a/packages/rspack-dev-server/etc/api.md +++ /dev/null @@ -1,84 +0,0 @@ -## API Report File for "@rspack/dev-server" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts - -/// - -import { Compiler } from '@rspack/core'; -import { DevServer as Configuration } from '@rspack/core'; -import type { FSWatcher } from 'chokidar'; -import { MultiCompiler } from '@rspack/core'; -import type { Server } from 'node:http'; -import type { Socket } from 'node:net'; -import WebpackDevServer from 'webpack-dev-server'; - -export { Configuration } - -// @public (undocumented) -interface ResolvedDevServer extends Configuration { - // (undocumented) - allowedHosts: "auto" | string[] | "all"; - // (undocumented) - bonjour: false | Record | WebpackDevServer.BonjourOptions; - // (undocumented) - client: WebpackDevServer.ClientConfiguration; - // (undocumented) - compress: boolean; - // (undocumented) - devMiddleware: Configuration["devMiddleware"]; - // (undocumented) - historyApiFallback: false | WebpackDevServer.ConnectHistoryApiFallbackOptions; - // (undocumented) - host?: string; - // (undocumented) - hot: boolean | "only"; - // (undocumented) - ipc: string | undefined; - // (undocumented) - liveReload: boolean; - // (undocumented) - magicHtml: boolean; - // (undocumented) - open: WebpackDevServer.Open[]; - // (undocumented) - port: number | string; - // (undocumented) - proxy: WebpackDevServer.ProxyConfigArray; - // (undocumented) - server: WebpackDevServer.ServerConfiguration; - // (undocumented) - setupExitSignals: boolean; - // (undocumented) - static: false | Array; - // (undocumented) - watchFiles: WebpackDevServer.WatchFiles[]; - // (undocumented) - webSocketServer: false | WebpackDevServer.WebSocketServerConfiguration; -} - -// @public (undocumented) -export class RspackDevServer extends WebpackDevServer { - constructor(options: Configuration, compiler: Compiler | MultiCompiler); - compiler: Compiler | MultiCompiler; - // (undocumented) - static getFreePort: (port: string, host: string) => Promise; - // (undocumented) - initialize(): Promise; - options: ResolvedDevServer; - // (undocumented) - server: Server; - // (undocumented) - sockets: Socket[]; - // (undocumented) - staticWatchers: FSWatcher[]; - // (undocumented) - static version: string; - // (undocumented) - webSocketServer: WebpackDevServer.WebSocketServerImplementation | undefined; -} - -// (No @packageDocumentation comment for this package) - -``` diff --git a/packages/rspack-dev-server/jest.config.js b/packages/rspack-dev-server/jest.config.js deleted file mode 100644 index f88ee4333f8..00000000000 --- a/packages/rspack-dev-server/jest.config.js +++ /dev/null @@ -1,46 +0,0 @@ -const os = require("node:os"); -const isWin = os.platform() === "win32"; -/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ -const config = { - preset: "ts-jest", - testEnvironmentOptions: { - url: "http://localhost/" - }, - testMatch: [ - "/tests/*.test.ts" - // TODO: enable after migrating to separated repo - // ...(isWin ? [] : ["/tests/e2e/*.test.js"]) - ], - testPathIgnorePatterns: isWin - ? [] - : [ - // TODO: check why http proxy server throw error with websocket server - "/tests/e2e/allowed-hosts.test.js", - // TODO: check why this test timeout - "/tests/e2e/host.test.js", - // TODO: check why this test throw error when run with other tests - "/tests/e2e/watch-files.test.js", - // TODO: check why this test timeout - "/tests/e2e/web-socket-server-url.test.js" - ], - cache: false, - testTimeout: process.env.CI ? 120000 : 30000, - transform: { - "(.*)\\.{js,ts}": [ - "ts-jest", - { - tsconfig: "/tests/tsconfig.json" - } - ] - }, - // Add this to find out which test timeouts - // testSequencer: "/tests/helpers/sequencer.js", - snapshotResolver: "/tests/helpers/snapshot-resolver.js", - setupFilesAfterEnv: ["/tests/helpers/setup-test.js"], - globalSetup: "/tests/helpers/global-setup-test.js", - moduleNameMapper: { - "^uuid$": require.resolve("uuid") - } -}; - -module.exports = config; diff --git a/packages/rspack-dev-server/package.json b/packages/rspack-dev-server/package.json deleted file mode 100644 index e448de7ecb7..00000000000 --- a/packages/rspack-dev-server/package.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "@rspack/dev-server", - "version": "1.0.5", - "license": "MIT", - "description": "Development server for rspack", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "publishConfig": { - "access": "public", - "provenance": true - }, - "exports": { - ".": { - "default": "./dist/index.js" - }, - "./client/*": "./client/*.js", - "./client/*.js": "./client/*.js", - "./package.json": "./package.json" - }, - "scripts": { - "build": "tsc -b ./tsconfig.build.json", - "dev": "tsc -w -b ./tsconfig.build.json", - "test:install": "cross-env ./node_modules/.bin/puppeteer browsers install chrome", - "test": "pnpm run test:install && cross-env NO_COLOR=1 node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --colors", - "api-extractor": "api-extractor run --verbose", - "api-extractor:ci": "api-extractor run --verbose || diff temp/api.md etc/api.md" - }, - "files": [ - "dist", - "client" - ], - "homepage": "https://rspack.dev", - "bugs": "https://github.com/web-infra-dev/rspack/issues", - "repository": { - "type": "git", - "url": "https://github.com/web-infra-dev/rspack", - "directory": "packages/rspack-dev-server" - }, - "devDependencies": { - "@jest/test-sequencer": "^29.7.0", - "@rspack/core": "workspace:*", - "@rspack/dev-server": "workspace:*", - "@rspack/plugin-react-refresh": "1.0.0", - "@types/connect-history-api-fallback": "1.5.4", - "@types/express": "4.17.21", - "@types/mime-types": "2.1.4", - "@types/ws": "8.5.10", - "css-loader": "^6.11.0", - "graceful-fs": "4.2.10", - "http-proxy": "^1.18.1", - "jest-serializer-path": "^0.1.15", - "prettier": "3.2.5", - "puppeteer": "^23.2.2", - "require-from-string": "^2.0.2", - "sockjs-client": "^1.6.1", - "style-loader": "^3.3.3", - "supertest": "^6.1.3", - "tcp-port-used": "^1.0.2", - "typescript": "5.0.2", - "wait-for-expect": "^3.0.2" - }, - "dependencies": { - "chokidar": "^3.6.0", - "connect-history-api-fallback": "^2.0.0", - "express": "^4.19.2", - "http-proxy-middleware": "^2.0.6", - "mime-types": "^2.1.35", - "p-retry": "4.6.2", - "webpack-dev-middleware": "^7.4.2", - "webpack-dev-server": "5.0.4", - "ws": "^8.16.0" - }, - "peerDependencies": { - "@rspack/core": "*" - } -} \ No newline at end of file diff --git a/packages/rspack-dev-server/src/alias.ts b/packages/rspack-dev-server/src/alias.ts deleted file mode 100644 index d5debd2f9a5..00000000000 --- a/packages/rspack-dev-server/src/alias.ts +++ /dev/null @@ -1,36 +0,0 @@ -const RESOLVER_MAP: Record = {}; -export const addResolveAlias = ( - name: string, - aliasMap: Record -) => { - const modulePath = require.resolve(name); - if (RESOLVER_MAP[modulePath]) { - throw new Error(`Should not add resolve alias to ${name} again.`); - } - const m = require.cache[modulePath]; - if (!m) { - throw new Error("Failed to resolve webpack-dev-server."); - } - RESOLVER_MAP[modulePath] = m.require.resolve; - m.require.resolve = ((id: string, options?: any) => - aliasMap[id] || - RESOLVER_MAP[modulePath]!.apply(m.require, [ - id, - options - ])) as typeof require.resolve; -}; - -export const removeResolveAlias = (name: string) => { - const modulePath = require.resolve(name); - if (!RESOLVER_MAP[modulePath]) { - return; - } - const m = require.cache[modulePath]; - if (!m) { - throw new Error("Failed to resolve webpack-dev-server"); - } - if (RESOLVER_MAP[modulePath]) { - m.require.resolve = RESOLVER_MAP[modulePath]!; - delete RESOLVER_MAP[modulePath]; - } -}; diff --git a/packages/rspack-dev-server/src/ansiHTML.ts b/packages/rspack-dev-server/src/ansiHTML.ts deleted file mode 100644 index 52094c03caf..00000000000 --- a/packages/rspack-dev-server/src/ansiHTML.ts +++ /dev/null @@ -1,293 +0,0 @@ -/** - * The following code is modified based on - * https://github.com/mahdyar/ansi-html-community/blob/b86cc3f1fa1d118477877352f0eafe1a70fd20ab/index.js - * - * Supported: - * - added support for 24-bit RGB colors. - * - * Apache 2.0 Licensed - * Author @Tjatse - * https://github.com/mahdyar/ansi-html-community/blob/master/LICENSE - */ -interface AnsiHtmlTags { - open: typeof _openTags; - close: typeof _closeTags; -} - -type Option = T | null | undefined; - -type Match = { - advance: (n: number) => void; -} & Array; - -// Reference to https://github.com/sindresorhus/ansi-regex -const _regANSI = - /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/; - -const _defColors: Record> = { - reset: ["fff", "000"], // [FOREGROUND_COLOR, BACKGROUND_COLOR] - black: "000", - red: "ff0000", - green: "209805", - yellow: "e8bf03", - blue: "0000ff", - magenta: "ff00ff", - cyan: "00ffee", - lightgrey: "f0f0f0", - darkgrey: "888" -}; -const _styles: Record = { - 30: "black", - 31: "red", - 32: "green", - 33: "yellow", - 34: "blue", - 35: "magenta", - 36: "cyan", - 37: "lightgrey" -}; - -const _colorMode: Record = { - 2: "rgb" -}; - -const _openTags: Record Option)> = { - 1: "font-weight:bold", // bold - 2: "opacity:0.5", // dim - 3: "", // italic - 4: "", // underscore - 8: "display:none", // hidden - 9: "", // delete - 38: (match: Match) => { - // color - const mode = _colorMode[match[0]]; - if (mode === "rgb") { - const r = match[1]; - const g = match[2]; - const b = match[3]; - match.advance(4); - return `color: rgb(${r},${g},${b})`; - } - }, - 48: (match: Match) => { - // background color - const mode = _colorMode[match[0]]; - if (mode === "rgb") { - const r = match[1]; - const g = match[2]; - const b = match[3]; - match.advance(4); - return `background-color: rgb(${r},${g},${b})`; - } - } -}; - -const _openTagToCloseTag: Record = { - 3: "23", - 4: "24", - 9: "29" -}; - -const _closeTags: Record< - string, - string | ((ansiCodes: Option>) => string) -> = { - 0: ansiCodes => { - if (!ansiCodes) return ""; - if (!ansiCodes.length) return ""; - let code: Option; - let ret = ""; - while ((code = ansiCodes.pop())) { - const closeTag = _openTagToCloseTag[code]; - if (closeTag) { - ret += _closeTags[closeTag]; - continue; - } - ret += ""; - } - return ret; - }, - 23: "", // reset italic - 24: "", // reset underscore - 29: "" // reset delete -}; - -for (const n of [21, 22, 27, 28, 39, 49]) { - _closeTags[n] = ""; -} - -/** - * Normalize ';' | '' -> '' - */ -function normalizeSeq(seq: Option): Option { - if (seq === null || seq === undefined) return null; - if (seq.startsWith(";")) { - return seq.slice(1); - } - return seq; -} - -/** - * Converts text with ANSI color codes to HTML markup. - */ -export default function ansiHTML(text: string) { - // Returns the text if the string has no ANSI escape code. - if (!_regANSI.test(text)) { - return text; - } - - // Cache opened sequence. - const ansiCodes: string[] = []; - // Replace with markup. - //@ts-ignore TS1487 error - let ret = text.replace(/\033\[(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?m/g, m => { - const match = m.match(/(;?\d+)/g)?.map(normalizeSeq) as unknown as Match; - Object.defineProperty(match, "advance", { - value: function (count: number) { - this.splice(0, count); - } - }); - let rep = ""; - let seq: string; - while ((seq = match[0])) { - match.advance(1); - rep += applySeq(seq); - } - return rep; - - function applySeq(seq: string) { - let other = _openTags[seq]; - if ( - other && - (other = typeof other === "function" ? (other(match) as string) : other) - ) { - // If reset signal is encountered, we have to reset everything. - let ret = ""; - if (seq === "0") { - ret += ( - _closeTags[seq] as (ansiCodes: Option>) => string - )(ansiCodes); - } - // If current sequence has been opened, close it. - if (ansiCodes.indexOf(seq) !== -1) { - ansiCodes.pop(); - return ""; - } - // Open tag. - ansiCodes.push(seq); - return ret + (other[0] === "<" ? other : ``); - } - - const ct = _closeTags[seq]; - if (typeof ct === "function") { - return ct(ansiCodes); - } - if (ct) { - // Pop sequence - ansiCodes.pop(); - return ct; - } - return ""; - } - }); - - // Make sure tags are closed. - const l = ansiCodes.length; - l > 0 && (ret += Array(l + 1).join("")); - - return ret; -} - -/** - * Customize colors. - * @param {Object} colors reference to _defColors - */ -ansiHTML.setColors = (colors: typeof _defColors) => { - if (typeof colors !== "object") { - throw new Error("`colors` parameter must be an Object."); - } - - const _finalColors: typeof _defColors = {}; - for (const key in _defColors) { - let hex = colors.hasOwnProperty(key) ? colors[key] : null; - if (!hex) { - _finalColors[key] = _defColors[key]; - continue; - } - if ("reset" === key) { - if (typeof hex === "string") { - hex = [hex]; - } - if ( - !Array.isArray(hex) || - hex.length === 0 || - hex.some(h => typeof h !== "string") - ) { - throw new Error( - `The value of \`${key}\` property must be an Array and each item could only be a hex string, e.g.: FF0000` - ); - } - const defHexColor = _defColors[key]; - if (!hex[0]) { - hex[0] = defHexColor[0]; - } - if (hex.length === 1 || !hex[1]) { - hex = [hex[0]]; - hex.push(defHexColor[1]); - } - - hex = hex.slice(0, 2); - } else if (typeof hex !== "string") { - throw new Error( - `The value of \`${key}\` property must be a hex string, e.g.: FF0000` - ); - } - _finalColors[key] = hex; - } - _setTags(_finalColors); -}; - -/** - * Reset colors. - */ -ansiHTML.reset = () => { - _setTags(_defColors); -}; - -/** - * Expose tags, including open and close. - * @type {Object} - */ -ansiHTML.tags = {} as AnsiHtmlTags; - -if (Object.defineProperty) { - Object.defineProperty(ansiHTML.tags, "open", { - get: () => _openTags - }); - Object.defineProperty(ansiHTML.tags, "close", { - get: () => _closeTags - }); -} else { - ansiHTML.tags.open = _openTags; - ansiHTML.tags.close = _closeTags; -} - -function _setTags(colors: typeof _defColors) { - // reset all - _openTags["0"] = - `font-weight:normal;opacity:1;color:#${colors.reset[0]};background:#${colors.reset[1]}`; - // inverse - _openTags["7"] = `color:#${colors.reset[1]};background:#${colors.reset[0]}`; - // dark grey - _openTags["90"] = `color:#${colors.darkgrey}`; - - for (const code in _styles) { - const color = _styles[code]; - const oriColor = colors[color] || "000"; - _openTags[code] = `color:#${oriColor}`; - const codeInt = Number.parseInt(code); - _openTags[(codeInt + 10).toString()] = `background:#${oriColor}`; - } -} - -ansiHTML.reset(); diff --git a/packages/rspack-dev-server/src/config.ts b/packages/rspack-dev-server/src/config.ts deleted file mode 100644 index c3ea5c5d18e..00000000000 --- a/packages/rspack-dev-server/src/config.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { DevServer } from "@rspack/core"; -import type WebpackDevServer from "webpack-dev-server"; - -export type { DevServer }; - -export interface ResolvedDevServer extends DevServer { - port: number | string; - static: false | Array; - devMiddleware: DevServer["devMiddleware"]; - hot: boolean | "only"; - host?: string; - open: WebpackDevServer.Open[]; - magicHtml: boolean; - liveReload: boolean; - webSocketServer: false | WebpackDevServer.WebSocketServerConfiguration; - proxy: WebpackDevServer.ProxyConfigArray; - client: WebpackDevServer.ClientConfiguration; - allowedHosts: "auto" | string[] | "all"; - bonjour: false | Record | WebpackDevServer.BonjourOptions; - compress: boolean; - historyApiFallback: false | WebpackDevServer.ConnectHistoryApiFallbackOptions; - server: WebpackDevServer.ServerConfiguration; - ipc: string | undefined; - setupExitSignals: boolean; - watchFiles: WebpackDevServer.WatchFiles[]; -} diff --git a/packages/rspack-dev-server/src/index.ts b/packages/rspack-dev-server/src/index.ts deleted file mode 100644 index b3be3ab08eb..00000000000 --- a/packages/rspack-dev-server/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { RspackDevServer } from "./server"; -export type { DevServer as Configuration } from "@rspack/core"; diff --git a/packages/rspack-dev-server/src/middleware.ts b/packages/rspack-dev-server/src/middleware.ts deleted file mode 100644 index 8d3068639fc..00000000000 --- a/packages/rspack-dev-server/src/middleware.ts +++ /dev/null @@ -1,86 +0,0 @@ -import crypto from "node:crypto"; -import type { IncomingMessage } from "node:http"; -import { extname } from "node:path"; -import { parse } from "node:url"; -import type { Compilation, Compiler } from "@rspack/core"; -import type { RequestHandler, Response } from "express"; -import mime from "mime-types"; -import type wdm from "webpack-dev-middleware"; - -function etag(buf: any) { - const hash = crypto.createHash("sha256").update(buf).digest("hex"); - const etag = hash; - return etag; -} - -function createPublicPathGetter(compiler: Compiler) { - const raw = compiler.options.output.publicPath || "/"; - - if (typeof raw === "function") { - return (compilation?: Compilation) => - compilation ? compilation.getPath(raw) : raw({ hash: "XXXX" }, undefined); - } - if (/\[(hash|fullhash)[:\]]/.test(raw)) { - return (compilation?: Compilation) => - compilation ? compilation.getPath(raw) : `${raw.replace(/\/$/, "")}/`; - } - return () => `${raw.replace(/\/$/, "")}/`; -} - -export function getRspackMemoryAssets( - compiler: Compiler, - rdm: ReturnType -): RequestHandler { - const getPublicPath = createPublicPathGetter(compiler); - - return (req: IncomingMessage, res: Response, next: () => void) => { - const { method, url } = req; - if (method !== "GET") { - return next(); - } - - // css hmr will append query string, so here need to remove query string - // @ts-expect-error - const path = parse(url).pathname; - const publicPath = getPublicPath(compiler._lastCompilation); - // asset name is not start with /, so path need to slice 1 - // @ts-expect-error - const filename = path.startsWith(publicPath) - ? // @ts-expect-error - path.slice(publicPath.length) - : // @ts-expect-error - path.slice(1); - const buffer = - compiler._lastCompilation?.getAsset(filename) ?? - (() => { - const { index } = rdm.context.options; - const indexValue = - typeof index === "undefined" || typeof index === "boolean" - ? "index.html" - : index; - return compiler._lastCompilation?.getAsset(filename + indexValue); - })(); - if (!buffer) { - return next(); - } - let contentType: string; - if (filename === "") { - contentType = "text/html; charset=utf-8"; - } else { - contentType = - // @ts-expect-error - mime.contentType(extname(path)) || "text/plain; charset=utf-8"; - } - - const calcEtag = etag(buffer); - - const oldEtag = req.headers["if-none-match"]; - res.setHeader("Content-Type", contentType); - res.setHeader("ETag", calcEtag); - if (calcEtag === oldEtag) { - res.status(304).send(); - } else { - res.send(buffer); - } - }; -} diff --git a/packages/rspack-dev-server/src/patch.ts b/packages/rspack-dev-server/src/patch.ts deleted file mode 100644 index 357b682084a..00000000000 --- a/packages/rspack-dev-server/src/patch.ts +++ /dev/null @@ -1,35 +0,0 @@ -import WebpackDevServer from "webpack-dev-server"; - -let old: InstanceType["sendStats"] | undefined; - -function restoreDevServerPatch() { - // @ts-expect-error private API - WebpackDevServer.prototype.sendStats = old; -} - -// Patch webpack-dev-server to prevent it from failing to send stats. -// See https://github.com/web-infra-dev/rspack/pull/4028 for details. -function applyDevServerPatch() { - if (old) return restoreDevServerPatch; - - // @ts-expect-error private API - old = WebpackDevServer.prototype.sendStats; - - // @ts-expect-error private API - WebpackDevServer.prototype.sendStats = function sendStats__rspack_patched( - // @ts-expect-error - ...args - ) { - const stats = args[1]; - - if (!stats) { - return; - } - - return old.apply(this, args); - }; - - return restoreDevServerPatch; -} - -export { applyDevServerPatch }; diff --git a/packages/rspack-dev-server/src/server.ts b/packages/rspack-dev-server/src/server.ts deleted file mode 100644 index e027a3d49f3..00000000000 --- a/packages/rspack-dev-server/src/server.ts +++ /dev/null @@ -1,120 +0,0 @@ -/** - * The following code is modified based on - * https://github.com/webpack/webpack-dev-server/blob/b0f15ace0123c125d5870609ef4691c141a6d187/lib/Server.js - * - * MIT Licensed - * Author Tobias Koppers @sokra - * Copyright (c) JS Foundation and other contributors - * https://github.com/webpack/webpack-dev-server/blob/b0f15ace0123c125d5870609ef4691c141a6d187/LICENSE - */ -import path from "node:path"; - -import type { Server } from "node:http"; -import type { Socket } from "node:net"; -import { type Compiler, MultiCompiler } from "@rspack/core"; -import type { FSWatcher } from "chokidar"; -import WebpackDevServer from "webpack-dev-server"; -// @ts-ignore 'package.json' is not under 'rootDir' -import { version } from "../package.json"; - -import { addResolveAlias, removeResolveAlias } from "./alias"; -import type { DevServer, ResolvedDevServer } from "./config"; -import { applyDevServerPatch } from "./patch"; - -applyDevServerPatch(); - -const getFreePort = async function getFreePort(port: string, host: string) { - if (typeof port !== "undefined" && port !== null && port !== "auto") { - return port; - } - - const pRetry = require("p-retry"); - const getPort = require("webpack-dev-server/lib/getPort"); - const basePort = - typeof process.env.WEBPACK_DEV_SERVER_BASE_PORT !== "undefined" - ? Number.parseInt(process.env.WEBPACK_DEV_SERVER_BASE_PORT, 10) - : 8080; - - // Try to find unused port and listen on it for 3 times, - // if port is not specified in options. - const defaultPortRetry = - typeof process.env.WEBPACK_DEV_SERVER_PORT_RETRY !== "undefined" - ? Number.parseInt(process.env.WEBPACK_DEV_SERVER_PORT_RETRY, 10) - : 3; - - return pRetry(() => getPort(basePort, host), { - retries: defaultPortRetry - }); -}; - -WebpackDevServer.getFreePort = getFreePort; - -export class RspackDevServer extends WebpackDevServer { - static getFreePort = getFreePort; - /** - * resolved after `normalizedOptions` - */ - declare options: ResolvedDevServer; - - declare staticWatchers: FSWatcher[]; - - declare sockets: Socket[]; - - declare server: Server; - // TODO: remove @ts-ignore here - /** @ts-ignore */ - public compiler: Compiler | MultiCompiler; - public webSocketServer: - | WebpackDevServer.WebSocketServerImplementation - | undefined; - static version: string = version; - - constructor(options: DevServer, compiler: Compiler | MultiCompiler) { - super(options, compiler as any); - // override - } - - async initialize() { - const compilers = - this.compiler instanceof MultiCompiler - ? this.compiler.compilers - : [this.compiler]; - - for (const compiler of compilers) { - const mode = compiler.options.mode || process.env.NODE_ENV; - if (this.options.hot) { - if (mode === "production") { - this.logger.warn( - "Hot Module Replacement (HMR) is enabled for the production build. \n" + - "Make sure to disable HMR for production by setting `devServer.hot` to `false` in the configuration." - ); - } - - compiler.options.resolve.alias = { - "ansi-html-community": path.resolve(__dirname, "./ansiHTML"), - ...compiler.options.resolve.alias - }; - } - } - - // @ts-expect-error - await super.initialize(); - } - - // @ts-ignore - private override addAdditionalEntries(compiler: Compiler) { - addResolveAlias("webpack-dev-server", { - "../client/index.js": require.resolve("@rspack/dev-server/client/index"), - "webpack/hot/only-dev-server": require.resolve( - "@rspack/core/hot/only-dev-server" - ), - "webpack/hot/dev-server": require.resolve("@rspack/core/hot/dev-server") - }); - try { - // @ts-expect-error - super.addAdditionalEntries(compiler); - } finally { - removeResolveAlias("webpack-dev-server"); - } - } -} diff --git a/packages/rspack-dev-server/tests/ansiHTML.test.ts b/packages/rspack-dev-server/tests/ansiHTML.test.ts deleted file mode 100644 index 079523d14f4..00000000000 --- a/packages/rspack-dev-server/tests/ansiHTML.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -import ansiHTML from "../src/ansiHTML"; - -describe("ansi-html", () => { - it("should transform 24-bit rgb ansi colors", () => { - expect(ansiHTML("\u001b[38;2;255;30;30m×\u001b[0m")).toMatchInlineSnapshot( - `"×"` - ); - }); - - it("should transform 24-bit rgb ansi colors with additional properties", () => { - expect( - ansiHTML("[\u001b[38;2;92;157;255;1;4m/root/index.js\u001b[0m:1:1]") - ).toMatchInlineSnapshot( - `"[/root/index.js:1:1]"` - ); - }); - - it("should transform basic ansi colors", () => { - expect(ansiHTML("\u001b[0mcontent")).toMatchInlineSnapshot( - `"content"` - ); - expect( - ansiHTML( - `\u001b[33m<\u001b[39m\u001b[33mheader\u001b[39m\u001b[33m>\u001b[39m` - ) - ).toMatchInlineSnapshot( - `"<header>"` - ); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/allowed-hosts.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/allowed-hosts.test.js.snap.webpack5 deleted file mode 100644 index 9def00ed4c6..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/allowed-hosts.test.js.snap.webpack5 +++ /dev/null @@ -1,327 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`allowed hosts check host headers should allow hosts in allowedHosts: console messages 1`] = `[]`; - -exports[`allowed hosts check host headers should allow hosts in allowedHosts: page errors 1`] = `[]`; - -exports[`allowed hosts check host headers should allow hosts in allowedHosts: response status 1`] = `200`; - -exports[`allowed hosts check host headers should allow hosts that pass a wildcard in allowedHosts: console messages 1`] = `[]`; - -exports[`allowed hosts check host headers should allow hosts that pass a wildcard in allowedHosts: page errors 1`] = `[]`; - -exports[`allowed hosts check host headers should allow hosts that pass a wildcard in allowedHosts: response status 1`] = `200`; - -exports[`allowed hosts check host headers should always allow \`localhost\` if options.allowedHosts is auto: console messages 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow \`localhost\` if options.allowedHosts is auto: page errors 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow \`localhost\` if options.allowedHosts is auto: response status 1`] = `200`; - -exports[`allowed hosts check host headers should always allow \`localhost\` subdomain if options.allowedHosts is auto: console messages 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow \`localhost\` subdomain if options.allowedHosts is auto: page errors 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow \`localhost\` subdomain if options.allowedHosts is auto: response status 1`] = `200`; - -exports[`allowed hosts check host headers should always allow any host if options.allowedHosts is all: console messages 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow any host if options.allowedHosts is all: page errors 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow any host if options.allowedHosts is all: response status 1`] = `200`; - -exports[`allowed hosts check host headers should always allow value of the \`host\` option from the \`client.webSocketURL\` option if options.allowedHosts is auto: console messages 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow value of the \`host\` option from the \`client.webSocketURL\` option if options.allowedHosts is auto: page errors 1`] = `[]`; - -exports[`allowed hosts check host headers should always allow value of the \`host\` option from the \`client.webSocketURL\` option if options.allowedHosts is auto: response status 1`] = `200`; - -exports[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server with the "auto" value ("sockjs"): 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[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server with the "auto" value ("ws"): 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[`allowed hosts should connect web socket client using "127.0.0.1" host to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using "chrome-extension:" protocol to web socket server with the "auto" value ("sockjs"): 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[`allowed hosts should connect web socket client using "chrome-extension:" protocol to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using "chrome-extension:" protocol to web socket server with the "auto" value ("ws"): 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[`allowed hosts should connect web socket client using "chrome-extension:" protocol to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using "file:" protocol to web socket server with the "auto" value ("sockjs"): 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[`allowed hosts should connect web socket client using "file:" protocol to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using "file:" protocol to web socket server with the "auto" value ("ws"): 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[`allowed hosts should connect web socket client using "file:" protocol to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value ("sockjs"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value ("ws"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value in array ("sockjs"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value in array ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value in array ("ws"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the "all" value in array ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value ("sockjs"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value ("ws"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value starting with dot ("sockjs"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value starting with dot ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value starting with dot ("ws"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the custom hostname value starting with dot ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the multiple custom hostname values ("sockjs"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the multiple custom hostname values ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom hostname to web socket server with the multiple custom hostname values ("ws"): 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[`allowed hosts should connect web socket client using custom hostname to web socket server with the multiple custom hostname values ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom sub hostname to web socket server with the custom hostname value ("sockjs"): 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[`allowed hosts should connect web socket client using custom sub hostname to web socket server with the custom hostname value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using custom sub hostname to web socket server with the custom hostname value ("ws"): 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[`allowed hosts should connect web socket client using custom sub hostname to web socket server with the custom hostname value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using localhost to web socket server with the "auto" value ("sockjs"): 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[`allowed hosts should connect web socket client using localhost to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should connect web socket client using localhost to web socket server with the "auto" value ("ws"): 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[`allowed hosts should connect web socket client using localhost to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): console messages 1`] = `[]`; - -exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): html 1`] = `"Invalid Host header"`; - -exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): console messages 1`] = `[]`; - -exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): html 1`] = `"Invalid Host header"`; - -exports[`allowed hosts should disconnect web client using localhost to web socket server with the "auto" value ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("sockjs"): 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.", - "[webpack-dev-server] Invalid Host/Origin header", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("ws"): 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.", - "[webpack-dev-server] Invalid Host/Origin header", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header when "server: 'https'" is enabled ("sockjs"): 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.", - "[webpack-dev-server] Invalid Host/Origin header", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header when "server: 'https'" is enabled ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header when "server: 'https'" is enabled ("ws"): 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.", - "[webpack-dev-server] Invalid Host/Origin header", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header when "server: 'https'" is enabled ("ws"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "origin" header ("sockjs"): 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.", - "[webpack-dev-server] Invalid Host/Origin header", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "origin" header ("sockjs"): page errors 1`] = `[]`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "origin" header ("ws"): 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.", - "[webpack-dev-server] Invalid Host/Origin header", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`allowed hosts should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "origin" header ("ws"): page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/api.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/api.test.js.snap.webpack5 deleted file mode 100644 index 4e25295ce5a..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/api.test.js.snap.webpack5 +++ /dev/null @@ -1,145 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`API Invalidate callback should use the default \`noop\` callback when invalidate is called without any callback: 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[`API Invalidate callback should use the default \`noop\` callback when invalidate is called without any callback: page errors 1`] = `[]`; - -exports[`API Invalidate callback should use the default \`noop\` callback when invalidate is called without any callback: response status 1`] = `200`; - -exports[`API Invalidate callback should use the provided \`callback\` function: 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[`API Invalidate callback should use the provided \`callback\` function: page errors 1`] = `[]`; - -exports[`API Invalidate callback should use the provided \`callback\` function: response status 1`] = `200`; - -exports[`API Server.checkHostHeader should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object: page errors 1`] = `[]`; - -exports[`API Server.checkHostHeader should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object: response status 1`] = `200`; - -exports[`API Server.checkHostHeader should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object: web socket URL 1`] = `"ws://test.host:8158/ws"`; - -exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): 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[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): page errors 1`] = `[]`; - -exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (number): response status 1`] = `200`; - -exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): 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[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): page errors 1`] = `[]`; - -exports[`API Server.getFreePort should retry finding the port for up to defaultPortRetry times (string): response status 1`] = `200`; - -exports[`API Server.getFreePort should retry finding the port when serial ports are busy: 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[`API Server.getFreePort should retry finding the port when serial ports are busy: page errors 1`] = `[]`; - -exports[`API Server.getFreePort should retry finding the port when serial ports are busy: response status 1`] = `200`; - -exports[`API Server.getFreePort should return the port when the port is \`null\`: 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[`API Server.getFreePort should return the port when the port is \`null\`: page errors 1`] = `[]`; - -exports[`API Server.getFreePort should return the port when the port is \`null\`: response status 1`] = `200`; - -exports[`API Server.getFreePort should return the port when the port is undefined: 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[`API Server.getFreePort should return the port when the port is undefined: page errors 1`] = `[]`; - -exports[`API Server.getFreePort should return the port when the port is undefined: response status 1`] = `200`; - -exports[`API Server.getFreePort should throw the error when the port isn't found 1`] = `"busy"`; - -exports[`API WEBPACK_SERVE environment variable should be present: 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[`API WEBPACK_SERVE environment variable should be present: page errors 1`] = `[]`; - -exports[`API WEBPACK_SERVE environment variable should be present: response status 1`] = `200`; - -exports[`API latest async API should work and allow to rerun dev server multiple times: 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[`API latest async API should work and allow to rerun dev server multiple times: page errors 1`] = `[]`; - -exports[`API latest async API should work when using configured manually: console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay disabled.", - "Hey.", -] -`; - -exports[`API latest async API should work when using configured manually: page errors 1`] = `[]`; - -exports[`API latest async API should work with async API: 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[`API latest async API should work with async API: page errors 1`] = `[]`; - -exports[`API latest async API should work with callback API: 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[`API latest async API should work with callback API: page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/bonjour.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/bonjour.test.js.snap.webpack5 deleted file mode 100644 index 1fac84312b4..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/bonjour.test.js.snap.webpack5 +++ /dev/null @@ -1,49 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`bonjour option as object should apply bonjour options: 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[`bonjour option as object should apply bonjour options: page errors 1`] = `[]`; - -exports[`bonjour option as object should apply bonjour options: response status 1`] = `200`; - -exports[`bonjour option as true should call bonjour with correct params: 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[`bonjour option as true should call bonjour with correct params: page errors 1`] = `[]`; - -exports[`bonjour option as true should call bonjour with correct params: response status 1`] = `200`; - -exports[`bonjour option bonjour object and 'server' option should apply bonjour options: 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[`bonjour option bonjour object and 'server' option should apply bonjour options: page errors 1`] = `[]`; - -exports[`bonjour option bonjour object and 'server' option should apply bonjour options: response status 1`] = `200`; - -exports[`bonjour option with 'server' option should call bonjour with 'https' type: 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[`bonjour option with 'server' option should call bonjour with 'https' type: page errors 1`] = `[]`; - -exports[`bonjour option with 'server' option should call bonjour with 'https' type: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/built-in-routes.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/built-in-routes.test.js.snap.webpack5 deleted file mode 100644 index 769c716c67f..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/built-in-routes.test.js.snap.webpack5 +++ /dev/null @@ -1,83 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Built in routes with multi config should handle GET request to directory index and list all middleware directories: console messages 1`] = `[]`; - -exports[`Built in routes with multi config should handle GET request to directory index and list all middleware directories: directory list 1`] = ` -"

Assets Report:

Compilation: unnamed[0]

Compilation: named

Compilation: other

" -`; - -exports[`Built in routes with multi config should handle GET request to directory index and list all middleware directories: page errors 1`] = `[]`; - -exports[`Built in routes with multi config should handle GET request to directory index and list all middleware directories: response headers content-type 1`] = `"text/html"`; - -exports[`Built in routes with multi config should handle GET request to directory index and list all middleware directories: response status 1`] = `200`; - -exports[`Built in routes with simple config should handle GET request to directory index and list all middleware directories: console messages 1`] = `[]`; - -exports[`Built in routes with simple config should handle GET request to directory index and list all middleware directories: directory list 1`] = ` -"

Assets Report:

Compilation: unnamed

" -`; - -exports[`Built in routes with simple config should handle GET request to directory index and list all middleware directories: page errors 1`] = `[]`; - -exports[`Built in routes with simple config should handle GET request to directory index and list all middleware directories: response headers content-type 1`] = `"text/html"`; - -exports[`Built in routes with simple config should handle GET request to directory index and list all middleware directories: response status 1`] = `200`; - -exports[`Built in routes with simple config should handle GET request to invalidate endpoint: console messages 1`] = `[]`; - -exports[`Built in routes with simple config should handle GET request to invalidate endpoint: page errors 1`] = `[]`; - -exports[`Built in routes with simple config should handle GET request to invalidate endpoint: response status 1`] = `200`; - -exports[`Built in routes with simple config should handle GET request to magic async chunk: console messages 1`] = `[]`; - -exports[`Built in routes with simple config should handle GET request to magic async chunk: response headers content-type 1`] = `"application/javascript; charset=utf-8"`; - -exports[`Built in routes with simple config should handle GET request to magic async chunk: response status 1`] = `200`; - -exports[`Built in routes with simple config should handle HEAD request to directory index: console messages 1`] = `[]`; - -exports[`Built in routes with simple config should handle HEAD request to directory index: directory list 1`] = `""`; - -exports[`Built in routes with simple config should handle HEAD request to directory index: page errors 1`] = `[]`; - -exports[`Built in routes with simple config should handle HEAD request to directory index: response headers content-type 1`] = `"text/html"`; - -exports[`Built in routes with simple config should handle HEAD request to directory index: response status 1`] = `200`; - -exports[`Built in routes with simple config should handle HEAD request to magic async chunk: console messages 1`] = `[]`; - -exports[`Built in routes with simple config should handle HEAD request to magic async chunk: response headers content-type 1`] = `"application/javascript; charset=utf-8"`; - -exports[`Built in routes with simple config should handle HEAD request to magic async chunk: response status 1`] = `200`; - -exports[`Built in routes with simple config should handles GET request to sockjs bundle: console messages 1`] = `[]`; - -exports[`Built in routes with simple config should handles GET request to sockjs bundle: page errors 1`] = `[]`; - -exports[`Built in routes with simple config should handles GET request to sockjs bundle: response headers content-type 1`] = `"application/javascript"`; - -exports[`Built in routes with simple config should handles GET request to sockjs bundle: response status 1`] = `200`; - -exports[`Built in routes with simple config should handles HEAD request to sockjs bundle: console messages 1`] = `[]`; - -exports[`Built in routes with simple config should handles HEAD request to sockjs bundle: page errors 1`] = `[]`; - -exports[`Built in routes with simple config should handles HEAD request to sockjs bundle: response headers content-type 1`] = `"application/javascript"`; - -exports[`Built in routes with simple config should handles HEAD request to sockjs bundle: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/client-reconnect.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/client-reconnect.test.js.snap.webpack5 deleted file mode 100644 index dee90931c0e..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/client-reconnect.test.js.snap.webpack5 +++ /dev/null @@ -1,37 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`client.reconnect option specified as false should not try to reconnect: 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.", - "[webpack-dev-server] Disconnected!", -] -`; - -exports[`client.reconnect option specified as false should not try to reconnect: page errors 1`] = `[]`; - -exports[`client.reconnect option specified as false should not try to reconnect: response status 1`] = `200`; - -exports[`client.reconnect option specified as number should try to reconnect 2 times: 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.", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", - "WebSocket connection to 'ws://127.0.0.1:8163/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED", - "[webpack-dev-server] JSHandle@object", - "[webpack-dev-server] Trying to reconnect...", - "WebSocket connection to 'ws://127.0.0.1:8163/ws' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED", - "[webpack-dev-server] JSHandle@object", -] -`; - -exports[`client.reconnect option specified as number should try to reconnect 2 times: page errors 1`] = `[]`; - -exports[`client.reconnect option specified as number should try to reconnect 2 times: response status 1`] = `200`; - -exports[`client.reconnect option specified as true should try to reconnect unlimited times: page errors 1`] = `[]`; - -exports[`client.reconnect option specified as true should try to reconnect unlimited times: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/client.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/client.test.js.snap.webpack5 deleted file mode 100644 index fb39002b72c..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/client.test.js.snap.webpack5 +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`client option configure client entry should disable client entry: console messages 1`] = `[]`; - -exports[`client option configure client entry should disable client entry: page errors 1`] = `[]`; - -exports[`client option configure client entry should disable client entry: response status 1`] = `200`; - -exports[`client option default behaviour responds with a 200 status code for /ws path: console messages 1`] = `[]`; - -exports[`client option default behaviour responds with a 200 status code for /ws path: page errors 1`] = `[]`; - -exports[`client option default behaviour responds with a 200 status code for /ws path: response status 1`] = `200`; - -exports[`client option should respect path option responds with a 200 status code for /foo/test/bar path: console messages 1`] = `[]`; - -exports[`client option should respect path option responds with a 200 status code for /foo/test/bar path: page errors 1`] = `[]`; - -exports[`client option should respect path option responds with a 200 status code for /foo/test/bar path: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/compress.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/compress.test.js.snap.webpack5 deleted file mode 100644 index 3aac8d779a6..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/compress.test.js.snap.webpack5 +++ /dev/null @@ -1,25 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`compress option as false should handle GET request to bundle file: console messages 1`] = `[]`; - -exports[`compress option as false should handle GET request to bundle file: page errors 1`] = `[]`; - -exports[`compress option as false should handle GET request to bundle file: response headers content-encoding 1`] = `undefined`; - -exports[`compress option as false should handle GET request to bundle file: response status 1`] = `200`; - -exports[`compress option as true should handle GET request to bundle file: console messages 1`] = `[]`; - -exports[`compress option as true should handle GET request to bundle file: page errors 1`] = `[]`; - -exports[`compress option as true should handle GET request to bundle file: response headers content-encoding 1`] = `"gzip"`; - -exports[`compress option as true should handle GET request to bundle file: response status 1`] = `200`; - -exports[`compress option enabled by default when not specified should handle GET request to bundle file: console messages 1`] = `[]`; - -exports[`compress option enabled by default when not specified should handle GET request to bundle file: page errors 1`] = `[]`; - -exports[`compress option enabled by default when not specified should handle GET request to bundle file: response headers content-encoding 1`] = `"gzip"`; - -exports[`compress option enabled by default when not specified should handle GET request to bundle file: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/entry.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/entry.test.js.snap.webpack5 deleted file mode 100644 index 7f320cd1ecc..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/entry.test.js.snap.webpack5 +++ /dev/null @@ -1,93 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`entry should work with dynamic async entry: 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[`entry should work with dynamic async entry: page errors 1`] = `[]`; - -exports[`entry should work with dynamic entry: 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[`entry should work with dynamic entry: page errors 1`] = `[]`; - -exports[`entry should work with empty: 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[`entry should work with empty: page errors 1`] = `[]`; - -exports[`entry should work with multiple entries #2: 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...", - "Bar.", -] -`; - -exports[`entry should work with multiple entries #2: page errors 1`] = `[]`; - -exports[`entry should work with multiple entries and "dependOn": 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...", - "Bar.", - "Hey.", -] -`; - -exports[`entry should work with multiple entries and "dependOn": page errors 1`] = `[]`; - -exports[`entry should work with multiple entries: 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[`entry should work with multiple entries: page errors 1`] = `[]`; - -exports[`entry should work with object entry: 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[`entry should work with object entry: page errors 1`] = `[]`; - -exports[`entry should work with single array entry: 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.", - "Bar.", -] -`; - -exports[`entry should work with single array entry: page errors 1`] = `[]`; - -exports[`entry should work with single entry: 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[`entry should work with single entry: page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/headers.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/headers.test.js.snap.webpack5 deleted file mode 100644 index 376a38e2440..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/headers.test.js.snap.webpack5 +++ /dev/null @@ -1,109 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`headers option as a function returning an array should handle GET request with headers: 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[`headers option as a function returning an array should handle GET request with headers: page errors 1`] = `[]`; - -exports[`headers option as a function returning an array should handle GET request with headers: response headers x-bar 1`] = `"value2"`; - -exports[`headers option as a function returning an array should handle GET request with headers: response headers x-foo 1`] = `"value1"`; - -exports[`headers option as a function returning an array should handle GET request with headers: response status 1`] = `200`; - -exports[`headers option as a function should handle GET request with headers as a function: 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[`headers option as a function should handle GET request with headers as a function: page errors 1`] = `[]`; - -exports[`headers option as a function should handle GET request with headers as a function: response headers x-bar 1`] = ` -"key1=value1 -key2=value2" -`; - -exports[`headers option as a function should handle GET request with headers as a function: response status 1`] = `200`; - -exports[`headers option as a string and support HEAD request should handle HEAD request with headers: 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[`headers option as a string and support HEAD request should handle HEAD request with headers: page errors 1`] = `[]`; - -exports[`headers option as a string and support HEAD request should handle HEAD request with headers: response headers x-foo 1`] = `"dev-server headers"`; - -exports[`headers option as a string and support HEAD request should handle HEAD request with headers: response status 1`] = `200`; - -exports[`headers option as a string should handle GET request with headers: 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[`headers option as a string should handle GET request with headers: page errors 1`] = `[]`; - -exports[`headers option as a string should handle GET request with headers: response headers x-foo 1`] = `"dev-server headers"`; - -exports[`headers option as a string should handle GET request with headers: response status 1`] = `200`; - -exports[`headers option as an array of objects should handle GET request with headers: 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[`headers option as an array of objects should handle GET request with headers: page errors 1`] = `[]`; - -exports[`headers option as an array of objects should handle GET request with headers: response headers x-bar 1`] = `"value2"`; - -exports[`headers option as an array of objects should handle GET request with headers: response headers x-foo 1`] = `"value1"`; - -exports[`headers option as an array of objects should handle GET request with headers: response status 1`] = `200`; - -exports[`headers option as an array should handle GET request with headers as an array: 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[`headers option as an array should handle GET request with headers as an array: page errors 1`] = `[]`; - -exports[`headers option as an array should handle GET request with headers as an array: response headers x-bar 1`] = ` -"key1=value1 -key2=value2" -`; - -exports[`headers option as an array should handle GET request with headers as an array: response status 1`] = `200`; - -exports[`headers option dev middleware headers take precedence for dev middleware output files should handle GET request with headers as a function: 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[`headers option dev middleware headers take precedence for dev middleware output files should handle GET request with headers as a function: page errors 1`] = `[]`; - -exports[`headers option dev middleware headers take precedence for dev middleware output files should handle GET request with headers as a function: response headers x-foo 1`] = `"dev-middleware-headers"`; - -exports[`headers option dev middleware headers take precedence for dev middleware output files should handle GET request with headers as a function: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack5 deleted file mode 100644 index 105d89d80d5..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/history-api-fallback.test.js.snap.webpack5 +++ /dev/null @@ -1,153 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`historyApiFallback option as boolean should handle GET request to directory: console messages 1`] = `[]`; - -exports[`historyApiFallback option as boolean should handle GET request to directory: page errors 1`] = `[]`; - -exports[`historyApiFallback option as boolean should handle GET request to directory: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`historyApiFallback option as boolean should handle GET request to directory: response status 1`] = `200`; - -exports[`historyApiFallback option as boolean should handle GET request to directory: response text 1`] = ` -"Heyyy -" -`; - -exports[`historyApiFallback option as object should handle GET request to directory: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object should handle GET request to directory: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object should handle GET request to directory: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`historyApiFallback option as object should handle GET request to directory: response status 1`] = `200`; - -exports[`historyApiFallback option as object should handle GET request to directory: response text 1`] = ` -"Foobar -" -`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect any other specified rewrites: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect any other specified rewrites: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect any other specified rewrites: response headers content-type 1`] = `"text/html; charset=UTF-8"`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect any other specified rewrites: response status 1`] = `200`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect any other specified rewrites: response text 1`] = ` -"Other file -" -`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites and shows index for unknown urls: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites and shows index for unknown urls: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites and shows index for unknown urls: response headers content-type 1`] = `"text/html; charset=UTF-8"`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites and shows index for unknown urls: response status 1`] = `200`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites and shows index for unknown urls: response text 1`] = ` -"Foobar -" -`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites for index: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites for index: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites for index: response headers content-type 1`] = `"text/html; charset=UTF-8"`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites for index: response status 1`] = `200`; - -exports[`historyApiFallback option as object with static and rewrites historyApiFallback respect rewrites for index: response text 1`] = ` -"Foobar -" -`; - -exports[`historyApiFallback option as object with static set to false historyApiFallback should work and ignore static content: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with static set to false historyApiFallback should work and ignore static content: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with static set to false historyApiFallback should work and ignore static content: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`historyApiFallback option as object with static set to false historyApiFallback should work and ignore static content: response status 1`] = `200`; - -exports[`historyApiFallback option as object with static set to false historyApiFallback should work and ignore static content: response text 1`] = ` -"In-memory file -" -`; - -exports[`historyApiFallback option as object with static should handle GET request to directory: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with static should handle GET request to directory: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with static should handle GET request to directory: response headers content-type 1`] = `"text/html; charset=UTF-8"`; - -exports[`historyApiFallback option as object with static should handle GET request to directory: response status 1`] = `200`; - -exports[`historyApiFallback option as object with static should handle GET request to directory: response text 1`] = ` -"Foobar -" -`; - -exports[`historyApiFallback option as object with static should prefer static file over historyApiFallback: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with static should prefer static file over historyApiFallback: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with static should prefer static file over historyApiFallback: response headers content-type 1`] = `"text/plain; charset=UTF-8"`; - -exports[`historyApiFallback option as object with static should prefer static file over historyApiFallback: response status 1`] = `200`; - -exports[`historyApiFallback option as object with static should prefer static file over historyApiFallback: response text 1`] = ` -"Random file -" -`; - -exports[`historyApiFallback option as object with the "logger" option request to directory and log: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with the "logger" option request to directory and log: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with the "logger" option request to directory and log: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`historyApiFallback option as object with the "logger" option request to directory and log: response status 1`] = `200`; - -exports[`historyApiFallback option as object with the "logger" option request to directory and log: response text 1`] = ` -"Foobar -" -`; - -exports[`historyApiFallback option as object with the "verbose" option request to directory and log: console messages 1`] = `[]`; - -exports[`historyApiFallback option as object with the "verbose" option request to directory and log: page errors 1`] = `[]`; - -exports[`historyApiFallback option as object with the "verbose" option request to directory and log: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`historyApiFallback option as object with the "verbose" option request to directory and log: response status 1`] = `200`; - -exports[`historyApiFallback option as object with the "verbose" option request to directory and log: response text 1`] = ` -"Foobar -" -`; - -exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response status 1`] = `"OK"`; - -exports[`historyApiFallback option in-memory files should perform HEAD request in same way as GET: response text 1`] = ` -"In-memory file -" -`; - -exports[`historyApiFallback option in-memory files should take precedence over static files: console messages 1`] = `[]`; - -exports[`historyApiFallback option in-memory files should take precedence over static files: page errors 1`] = `[]`; - -exports[`historyApiFallback option in-memory files should take precedence over static files: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`historyApiFallback option in-memory files should take precedence over static files: response status 1`] = `200`; - -exports[`historyApiFallback option in-memory files should take precedence over static files: response text 1`] = ` -"In-memory file -" -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/host.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/host.test.js.snap.webpack5 deleted file mode 100644 index 3aa742bc730..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/host.test.js.snap.webpack5 +++ /dev/null @@ -1,61 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`host should work using "127.0.0.1" host and "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[`host should work using "127.0.0.1" host and "auto" port: page errors 1`] = `[]`; - -exports[`host should work using "127.0.0.1" host and port as number: 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[`host should work using "127.0.0.1" host and port as number: page errors 1`] = `[]`; - -exports[`host should work using "127.0.0.1" host and port as string: 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[`host should work using "127.0.0.1" host and port as string: page errors 1`] = `[]`; - -exports[`host should work using "localhost" host and "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[`host should work using "localhost" host and "auto" port: page errors 1`] = `[]`; - -exports[`host should work using "localhost" host and port as number: 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[`host should work using "localhost" host and port as number: page errors 1`] = `[]`; - -exports[`host should work using "localhost" host and port as string: 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[`host should work using "localhost" host and port as string: page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/hot-and-live-reload.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/hot-and-live-reload.test.js.snap.webpack5 deleted file mode 100644 index 3d7a793295a..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/hot-and-live-reload.test.js.snap.webpack5 +++ /dev/null @@ -1,385 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`hot and live reload should not refresh content when hot and no live reload disabled (default): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[webpack-dev-server] App updated. Recompiling...", -] -`; - -exports[`hot and live reload should not refresh content when hot and no live reload disabled (default): page errors 1`] = `[]`; - -exports[`hot and live reload should not refresh content when hot and no live reload disabled (sockjs): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[webpack-dev-server] App updated. Recompiling...", -] -`; - -exports[`hot and live reload should not refresh content when hot and no live reload disabled (sockjs): page errors 1`] = `[]`; - -exports[`hot and live reload should not refresh content when hot and no live reload disabled (ws): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[webpack-dev-server] App updated. Recompiling...", -] -`; - -exports[`hot and live reload should not refresh content when hot and no live reload disabled (ws): page errors 1`] = `[]`; - -exports[`hot and live reload should work and allow to disable hot module replacement and live reload using the "webpack-dev-server-hot=false&webpack-dev-server-live-reload=false" (default): 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...", - "[webpack-dev-server] App updated. Recompiling...", -] -`; - -exports[`hot and live reload should work and allow to disable hot module replacement and live reload using the "webpack-dev-server-hot=false&webpack-dev-server-live-reload=false" (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and allow to disable hot module replacement using the "webpack-dev-server-hot=false" (default): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", -] -`; - -exports[`hot and live reload should work and allow to disable hot module replacement using the "webpack-dev-server-hot=false" (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and allow to disable live reload using the "webpack-dev-server-live-reload=false" (default): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[webpack-dev-server] App updated. Recompiling...", -] -`; - -exports[`hot and live reload should work and allow to disable live reload using the "webpack-dev-server-live-reload=false" (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and do nothing when web socket server disabled (default): console messages 1`] = `[]`; - -exports[`hot and live reload should work and do nothing when web socket server disabled (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement (default): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when hot enabled (default): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when hot enabled (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when hot enabled (sockjs): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when hot enabled (sockjs): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when hot enabled (ws): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when hot enabled (ws): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload and hot enabled (sockjs): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload and hot enabled (sockjs): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload and hot enabled (ws): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload and hot enabled (ws): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload disabled and hot enabled (default): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload disabled and hot enabled (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload disabled and hot enabled (sockjs): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload disabled and hot enabled (sockjs): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload disabled and hot enabled (ws): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload disabled and hot enabled (ws): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled (default): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled (sockjs): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled (sockjs): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled (ws): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled (ws): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled and hot disabled (default): 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...", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work and refresh content using hot module replacement when live reload enabled and hot disabled (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using live reload (default): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", -] -`; - -exports[`hot and live reload should work and refresh content using live reload (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using live reload when live reload disabled and hot enabled (sockjs): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", -] -`; - -exports[`hot and live reload should work and refresh content using live reload when live reload disabled and hot enabled (sockjs): page errors 1`] = `[]`; - -exports[`hot and live reload should work and refresh content using live reload when live reload enabled and hot disabled (ws): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", -] -`; - -exports[`hot and live reload should work and refresh content using live reload when live reload enabled and hot disabled (ws): page errors 1`] = `[]`; - -exports[`hot and live reload should work with manual client setup (default): console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay disabled.", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work with manual client setup (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work with manual client setup and allow to disable hot module replacement (default): console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay disabled.", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay disabled.", -] -`; - -exports[`hot and live reload should work with manual client setup and allow to disable hot module replacement (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work with manual client setup and allow to disable live reload (default): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay disabled.", - "[webpack-dev-server] App updated. Recompiling...", -] -`; - -exports[`hot and live reload should work with manual client setup and allow to disable live reload (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work with manual client setup and allow to enable hot module replacement (default): console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay disabled.", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Updated modules:", - "[HMR] - ./main.css", - "[HMR] - ../../../../../node_modules/.pnpm/css-loader@6.11.0_@rspack+core@packages+rspack_webpack@5.94.0_webpack-cli@5.1.4_webpack@5.94.0__/node_modules/css-loader/dist/cjs.js!./main.css", - "", - "[HMR] App is up to date.", -] -`; - -exports[`hot and live reload should work with manual client setup and allow to enable hot module replacement (default): page errors 1`] = `[]`; - -exports[`hot and live reload should work with manual client setup and allow to enable live reload (default): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay disabled.", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay disabled.", -] -`; - -exports[`hot and live reload should work with manual client setup and allow to enable live reload (default): page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/ipc.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/ipc.test.js.snap.webpack5 deleted file mode 100644 index b8508659b44..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/ipc.test.js.snap.webpack5 +++ /dev/null @@ -1,41 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`web socket server URL should work with the "ipc" option using "string" value ("sockjs"): 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[`web socket server URL should work with the "ipc" option using "string" value ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "ipc" option using "string" value ("ws"): 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[`web socket server URL should work with the "ipc" option using "string" value ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "ipc" option using "true" value ("sockjs"): 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[`web socket server URL should work with the "ipc" option using "true" value ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "ipc" option using "true" value ("ws"): 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[`web socket server URL should work with the "ipc" option using "true" value ("ws"): page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/logging.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/logging.test.js.snap.webpack5 deleted file mode 100644 index 6258a968c9f..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/logging.test.js.snap.webpack5 +++ /dev/null @@ -1,333 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`logging should work and do not log messages about hot and live reloading is enabled (sockjs) 1`] = ` -[ - [webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay enabled., - Hey., -] -`; - -exports[`logging should work and do not log messages about hot and live reloading is enabled (ws) 1`] = ` -[ - [webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading disabled, Progress disabled, Overlay enabled., - Hey., -] -`; - -exports[`logging should work and log errors by default (sockjs) 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., - [webpack-dev-server] Errors while compiling. Reload prevented., - [webpack-dev-server] ERROR - × Error: Error from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work and log errors by default (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..., - Hey., - [webpack-dev-server] Errors while compiling. Reload prevented., - [webpack-dev-server] ERROR - × Error: Error from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work and log message about live reloading is enabled (sockjs) 1`] = ` -[ - [webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled., - Hey., -] -`; - -exports[`logging should work and log message about live reloading is enabled (ws) 1`] = ` -[ - [webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled., - Hey., -] -`; - -exports[`logging should work and log messages about hot and live reloading is enabled (sockjs) 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[`logging should work and log messages about hot and live reloading is enabled (sockjs) 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[`logging should work and log messages about hot and live reloading is enabled (sockjs) 3`] = ` -[ - [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[`logging should work and log messages about hot and live reloading is enabled (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..., - Hey., -] -`; - -exports[`logging should work and log messages about hot and live reloading is enabled (ws) 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[`logging should work and log messages about hot and live reloading is enabled (ws) 3`] = ` -[ - [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[`logging should work and log messages about hot is enabled (sockjs) 1`] = ` -[ - [webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled., - [HMR] Waiting for update signal from WDS..., - Hey., -] -`; - -exports[`logging should work and log messages about hot is enabled (ws) 1`] = ` -[ - [webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled., - [HMR] Waiting for update signal from WDS..., - Hey., -] -`; - -exports[`logging should work and log only error (sockjs) 1`] = ` -[ - Hey., - [webpack-dev-server] Errors while compiling. Reload prevented., - [webpack-dev-server] ERROR - × Error: Error from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work and log only error (ws) 1`] = ` -[ - Hey., - [webpack-dev-server] Errors while compiling. Reload prevented., - [webpack-dev-server] ERROR - × Error: Error from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work and log static changes (sockjs) 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., - [webpack-dev-server] "/tests/fixtures/client-config/static/foo.txt" from static directory was changed. Reloading..., - [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[`logging should work and log static changes (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..., - Hey., - [webpack-dev-server] "/tests/fixtures/client-config/static/foo.txt" from static directory was changed. Reloading..., - [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[`logging should work and log warning and errors (sockjs) 1`] = ` -[ - Hey., - [webpack-dev-server] Warnings while compiling., - [webpack-dev-server] WARNING - ⚠ Error: Warning from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, - [webpack-dev-server] Errors while compiling. Reload prevented., - [webpack-dev-server] ERROR - × Error: Error from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work and log warning and errors (ws) 1`] = ` -[ - Hey., - [webpack-dev-server] Warnings while compiling., - [webpack-dev-server] WARNING - ⚠ Error: Warning from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, - [webpack-dev-server] Errors while compiling. Reload prevented., - [webpack-dev-server] ERROR - × Error: Error from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work and log warnings by default (sockjs) 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., - [webpack-dev-server] Warnings while compiling., - [webpack-dev-server] WARNING - ⚠ Error: Warning from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work and log warnings by default (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..., - Hey., - [webpack-dev-server] Warnings while compiling., - [webpack-dev-server] WARNING - ⚠ Error: Warning from compilation - │ at Object.fn (/tests/e2e/logging.test.js::) - │ at SyncHook.callAsyncStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at /packages/rspack/dist/Compiler.js:: - │ at last.function (/packages/rspack/dist/Compiler.js::) -, -] -`; - -exports[`logging should work when the "client.logging" is "info" (sockjs) 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[`logging should work when the "client.logging" is "info" (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..., - Hey., -] -`; - -exports[`logging should work when the "client.logging" is "log" (sockjs) 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[`logging should work when the "client.logging" is "log" (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..., - Hey., -] -`; - -exports[`logging should work when the "client.logging" is "none" (sockjs) 1`] = ` -[ - Hey., -] -`; - -exports[`logging should work when the "client.logging" is "none" (ws) 1`] = ` -[ - Hey., -] -`; - -exports[`logging should work when the "client.logging" is "verbose" (sockjs) 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[`logging should work when the "client.logging" is "verbose" (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..., - Hey., -] -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/mime-types.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/mime-types.test.js.snap.webpack5 deleted file mode 100644 index 62552683489..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/mime-types.test.js.snap.webpack5 +++ /dev/null @@ -1,17 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`mimeTypes option as an object with a custom type should request file with different js mime type: console messages 1`] = `[]`; - -exports[`mimeTypes option as an object with a custom type should request file with different js mime type: page errors 1`] = `[]`; - -exports[`mimeTypes option as an object with a custom type should request file with different js mime type: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`mimeTypes option as an object with a custom type should request file with different js mime type: response status 1`] = `200`; - -exports[`mimeTypes option as an object with a remapped type should request file with different js mime type: console messages 1`] = `[]`; - -exports[`mimeTypes option as an object with a remapped type should request file with different js mime type: page errors 1`] = `[]`; - -exports[`mimeTypes option as an object with a remapped type should request file with different js mime type: response headers content-type 1`] = `"text/plain; charset=utf-8"`; - -exports[`mimeTypes option as an object with a remapped type should request file with different js mime type: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/module-federation.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/module-federation.test.js.snap.webpack5 deleted file mode 100644 index 8d4ba07250a..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/module-federation.test.js.snap.webpack5 +++ /dev/null @@ -1,25 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Module federation should use plugin should contain hot script in main.js: console messages 1`] = `[]`; - -exports[`Module federation should use plugin should contain hot script in main.js: page errors 1`] = `[]`; - -exports[`Module federation should use plugin should contain hot script in remoteEntry.js: console messages 1`] = `[]`; - -exports[`Module federation should use plugin should contain hot script in remoteEntry.js: page errors 1`] = `[]`; - -exports[`Module federation should work with multi compiler config should use the last entry export: console messages 1`] = `[]`; - -exports[`Module federation should work with multi compiler config should use the last entry export: page errors 1`] = `[]`; - -exports[`Module federation should work with object multi-entry config should support the named entry export: console messages 1`] = `[]`; - -exports[`Module federation should work with object multi-entry config should support the named entry export: page errors 1`] = `[]`; - -exports[`Module federation should work with object multi-entry config should use the last entry export: console messages 1`] = `[]`; - -exports[`Module federation should work with object multi-entry config should use the last entry export: page errors 1`] = `[]`; - -exports[`Module federation should work with simple multi-entry config should use the last entry export: console messages 1`] = `[]`; - -exports[`Module federation should work with simple multi-entry config should use the last entry export: page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5 deleted file mode 100644 index 7a06874d381..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/multi-compiler.test.js.snap.webpack5 +++ /dev/null @@ -1,265 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`multi compiler should work with one web target configuration and do nothing: 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[`multi compiler should work with one web target configuration and do nothing: page errors 1`] = `[]`; - -exports[`multi compiler should work with universal configuration and do nothing: 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...", - "Hello from the browser", -] -`; - -exports[`multi compiler should work with universal configuration and do nothing: page errors 1`] = `[]`; - -exports[`multi compiler should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed: 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...", - "Hello from the browser", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Cannot apply update. Need to do a full reload!", - "[HMR] Error: Aborted because ./browser.js is not accepted -Update propagation: ./browser.js - ", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "Hello from the browser", -] -`; - -exports[`multi compiler should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed: page errors 1`] = `[]`; - -exports[`multi compiler should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed: console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "Hello from the browser", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Cannot apply update. Need to do a full reload!", - "[HMR] Error: Aborted because ./browser.js is not accepted -Update propagation: ./browser.js - ", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "Hello from the browser", -] -`; - -exports[`multi compiler should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed: page errors 1`] = `[]`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", -] -`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: console messages 2`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", -] -`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: page errors 1`] = `[]`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries: page errors 2`] = `[]`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", -] -`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: console messages 2`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "Hello from the browser", -] -`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: page errors 1`] = `[]`; - -exports[`multi compiler should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries: page errors 2`] = `[]`; - -exports[`multi compiler should work with web target configurations and do nothing: 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...", - "one", -] -`; - -exports[`multi compiler should work with web target configurations and do nothing: 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...", - "two", -] -`; - -exports[`multi compiler should work with web target configurations and do nothing: page errors 1`] = `[]`; - -exports[`multi compiler should work with web target configurations and do nothing: page errors 2`] = `[]`; - -exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: 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...", - "one", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Cannot apply update. Need to do a full reload!", - "[HMR] Error: Aborted because ./one.js is not accepted -Update propagation: ./one.js - ", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "one", -] -`; - -exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: 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...", - "two", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Cannot apply update. Need to do a full reload!", - "[HMR] Error: Aborted because ./two.js is not accepted -Update propagation: ./two.js - ", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "two", -] -`; - -exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: page errors 1`] = `[]`; - -exports[`multi compiler should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries: page errors 2`] = `[]`; - -exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "one", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Cannot apply update. Need to do a full reload!", - "[HMR] Error: Aborted because ./one.js is not accepted -Update propagation: ./one.js - ", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "one", -] -`; - -exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: console messages 2`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "two", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "[HMR] Cannot apply update. Need to do a full reload!", - "[HMR] Error: Aborted because ./two.js is not accepted -Update propagation: ./two.js - ", - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.", - "[HMR] Waiting for update signal from WDS...", - "two", -] -`; - -exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: page errors 1`] = `[]`; - -exports[`multi compiler should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries: page errors 2`] = `[]`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "one", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "one", -] -`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: console messages 2`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "two", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "two", -] -`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: page errors 1`] = `[]`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled and do live reload when changing other entries: page errors 2`] = `[]`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "one", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "one", -] -`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: console messages 2`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "two", - "[webpack-dev-server] App updated. Recompiling...", - "[webpack-dev-server] App updated. Reloading...", - "[webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled.", - "two", -] -`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: page errors 1`] = `[]`; - -exports[`multi compiler should work with web target configurations when only live reload is enabled, and do live reload when changing own entries: page errors 2`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/on-listening.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/on-listening.test.js.snap.webpack5 deleted file mode 100644 index 3a34989809a..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/on-listening.test.js.snap.webpack5 +++ /dev/null @@ -1,21 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`onListening option should handle GET request to /listening/some/path route: console messages 1`] = `[]`; - -exports[`onListening option should handle GET request to /listening/some/path route: page errors 1`] = `[]`; - -exports[`onListening option should handle GET request to /listening/some/path route: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`onListening option should handle GET request to /listening/some/path route: response status 1`] = `200`; - -exports[`onListening option should handle GET request to /listening/some/path route: response text 1`] = `"listening"`; - -exports[`onListening option should handle POST request to /listening/some/path route: console messages 1`] = `[]`; - -exports[`onListening option should handle POST request to /listening/some/path route: page errors 1`] = `[]`; - -exports[`onListening option should handle POST request to /listening/some/path route: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`onListening option should handle POST request to /listening/some/path route: response status 1`] = `200`; - -exports[`onListening option should handle POST request to /listening/some/path route: response text 1`] = `"listening POST"`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/overlay.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/overlay.test.js.snap.webpack5 deleted file mode 100644 index 94441ff128a..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/overlay.test.js.snap.webpack5 +++ /dev/null @@ -1,3126 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`overlay should not show a warning when "client.overlay" is "false": page html 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show a warning when "client.overlay.warnings" is "false": page html 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show an error when "client.overlay" is "false": page html 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show an error when "client.overlay.errors" is "false": page html 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show initially, then show on an error and allow to close: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR in ./foo.js -
-
- × Module parse failed: ╰─▶ × JavaScript parsing error: Unexpected eof - ╭──── 1 │ \`; ╰──── help: You may need an appropriate loader to handle - this file type. -
-
-
-
- - -`; - -exports[`overlay should not show initially, then show on an error and allow to close: page html after close 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show initially, then show on an error and allow to close: page html initial 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show initially, then show on an error and allow to close: page html with error 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should not show initially, then show on an error, then hide on fix: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR in ./foo.js -
-
- × Module parse failed: ╰─▶ × JavaScript parsing error: Unexpected eof - ╭──── 1 │ \`; ╰──── help: You may need an appropriate loader to handle - this file type. -
-
-
-
- - -`; - -exports[`overlay should not show initially, then show on an error, then hide on fix: page html after fix error 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show initially, then show on an error, then hide on fix: page html initial 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show initially, then show on an error, then hide on fix: page html with error 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should not show initially, then show on an error, then show other error, then hide on fix: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR in ./foo.js -
-
- × Module parse failed: ╰─▶ × JavaScript parsing error: Unexpected eof - ╭──── 1 │ \`; ╰──── help: You may need an appropriate loader to handle - this file type. -
-
-
-
- - -`; - -exports[`overlay should not show initially, then show on an error, then show other error, then hide on fix: overlay html 2`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR in ./foo.js -
-
- × Module parse failed: ╰─▶ × JavaScript parsing error: Unexpected eof - ╭──── 1 │ \`;a ╰──── help: You may need an appropriate loader to handle - this file type. -
-
-
-
- - -`; - -exports[`overlay should not show initially, then show on an error, then show other error, then hide on fix: page html after fix error 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show initially, then show on an error, then show other error, then hide on fix: page html initial 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should not show initially, then show on an error, then show other error, then hide on fix: page html with error 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should not show initially, then show on an error, then show other error, then hide on fix: page html with other error 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should not show overlay when Trusted Types are enabled, but policy is not allowed: page html 1`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should show a warning after invalidation: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning after invalidation: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show a warning and error for initial compilation and protects against xss: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- ⚠ Error: <strong>strong</strong> │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- ERROR -
-
- × Error: <strong>strong</strong> │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning and error for initial compilation and protects against xss: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show a warning and error for initial compilation: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- ERROR -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning and error for initial compilation: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show a warning and hide them after closing connection: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning and hide them after closing connection: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show a warning and hide them after closing connection: page html 2`] = ` - -

webpack-dev-server is running...

- - - -`; - -exports[`overlay should show a warning for initial compilation: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning for initial compilation: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show a warning when "client.overlay" is "true": overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning when "client.overlay" is "true": page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show a warning when "client.overlay.errors" is "true": overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning when "client.overlay.errors" is "true": page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show a warning when "client.overlay.warnings" is "true": overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show a warning when "client.overlay.warnings" is "true": page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show an ansi formatted error for initial compilation: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: - - 18 | - Render - ansi formatted text - │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) - -
-
-
-
- - -`; - -exports[`overlay should show an ansi formatted error for initial compilation: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show an error after invalidation: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Error from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show an error after invalidation: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show an error for initial compilation: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show an error for initial compilation: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show an error when "client.overlay" is "true": overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show an error when "client.overlay" is "true": page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show an error when "client.overlay.errors" is "true": overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show an error when "client.overlay.errors" is "true": page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show an error when "client.overlay.warnings" is "true": overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Warning from compilation │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show an error when "client.overlay.warnings" is "true": page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show error for uncaught promise rejection: overlay html 1`] = ` - -
-
- Uncaught runtime errors: -
- -
-
-
- ERROR -
-
- Async error at <anonymous>:: -
-
-
-
- - -`; - -exports[`overlay should show error for uncaught runtime error: overlay html 1`] = ` - -
-
- Uncaught runtime errors: -
- -
-
-
- ERROR -
-
- Injected error at throwError (<anonymous>::) at - <anonymous>:: -
-
-
-
- - -`; - -exports[`overlay should show error when it is not filtered: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Unfiltered error │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show error when it is not filtered: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show overlay when "Content-Security-Policy" is "default-src 'self'" was used: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show overlay when "Content-Security-Policy" is "default-src 'self'" was used: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show overlay when Trusted Types are enabled and the "require-trusted-types-for 'script'" header was used: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show overlay when Trusted Types are enabled and the "require-trusted-types-for 'script'" header was used: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show overlay when Trusted Types are enabled: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- ERROR -
-
- × Error: Error from compilation. Can't find 'test' module. │ at - Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show overlay when Trusted Types are enabled: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; - -exports[`overlay should show warning when it is not filtered: overlay html 1`] = ` - -
-
- Compiled with problems: -
- -
-
-
- WARNING -
-
- ⚠ Error: Unfiltered warning │ at Object.fn - (/tests/e2e/overlay.test.js::) - │ at SyncHook.callAsyncStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at SyncHook.callStageRange - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at QueriedHook.call - (/node_modules/.pnpm/@rspack+lite-tapable@1.0.0/node_modules/@rspack/lite-tapable/dist/index.js::) - │ at - /packages/rspack/dist/Compiler.js:: - │ at last.function - (/packages/rspack/dist/Compiler.js::) -
-
-
-
- - -`; - -exports[`overlay should show warning when it is not filtered: page html 1`] = ` - -

webpack-dev-server is running...

- - - - - -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/port.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/port.test.js.snap.webpack5 deleted file mode 100644 index 56c9509a19d..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/port.test.js.snap.webpack5 +++ /dev/null @@ -1,61 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`port should work using "" 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 "" 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`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/server-and-client-transport.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/server-and-client-transport.test.js.snap.webpack5 deleted file mode 100644 index 6fa2cfc536f..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/server-and-client-transport.test.js.snap.webpack5 +++ /dev/null @@ -1,107 +0,0 @@ -// 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...", -] -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/server.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/server.test.js.snap.webpack5 deleted file mode 100644 index dabcd217098..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/server.test.js.snap.webpack5 +++ /dev/null @@ -1,604 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`server option as object allow to pass more options should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object allow to pass more options should handle GET request to index route (/): https options 1`] = ` -{ - "ca": "", - "cert": "", - "key": "", - "minVersion": "TLSv1.1", - "passphrase": "webpack-dev-server", - "pfx": "", - "requestCert": false, -} -`; - -exports[`server option as object allow to pass more options should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object allow to pass more options should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object allow to pass more options should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): https options 1`] = ` -{ - "ca": [ - "", - ], - "cert": [ - "", - ], - "key": [ - "", - ], - "passphrase": "webpack-dev-server", - "pfx": [ - "", - ], - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are array of buffers should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): https options 1`] = ` -{ - "ca": [ - "", - ], - "cert": [ - "", - ], - "key": [ - "", - ], - "passphrase": "webpack-dev-server", - "pfx": [ - "", - ], - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are array of paths to files should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): https options 1`] = ` -{ - "ca": [ - "-----BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv -C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu -Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs -EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw -duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ -T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J -G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu -CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 -oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ -tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc -pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k+s7c4c5X7XDm3X0GWeSbqBMJb8q7 -BhZQNzECgYEA4kAtymDBvFYiZFq7+lzQBRKAI1RCq7YqxlieumH0PSkie2bba3dW -NVdTi7at8+GDB9/cHUPKzg/skfJllek57MZmusiVwB/Lmp/IlW8YyGShdYZ7zQsV -KMWJljpky3BEDM5sb08wIkfrOkelI/S4Bqqabd9JzOMJzoTiVOlMam8CgYEA3ctN -yonWz2bsnCUstQvQCLdI5a8Q7GJvlH2awephxGXIKGUuRmyyop0AnRnIBEWtOQV7 -yZjW32bU+Wt+2BJ247EyJiIQ4gT+T51t+v/Wt1YNbL3dSj9ttOvwYd4H2W4E7EIO -GKIF4I39FM7r8NfG7YE7S1aVcnrqs01N3nhd9HMCgYEAjepbzpmqbAxLPk97oase -AFB+d6qetz5ozklAJwDSRprKukTmVR5hwMup5/UKX/OQURwl4WVojKCIb3NwLPxC -DTbVsUuoQv6uo6qeEr3A+dHFRQa6GP9eolhl2Ql/t+wPg0jn01oEgzxBXCkceNVD -qUrR2yE4FYBD4nqPzVsZR5kCgYEA1yTi7NkQeldIpZ6Z43T18753A/Xx4JsLyWqd -uAT3mV9x7V1Yqg++qGbLtZjQoPRFt85N6ZxMsqA5b0iK3mXq1auJDdx1rAlT9z6q -9JM/YNAkbZsvEVq9vIYxw31w98T1GYhpzBM+yDhzir+9tv5YhQKa1dXDWi1JhWwz -YN45pWkCgYEAxuVsJ4D4Th5o050ppWpnxM/WuMhIUKqaoFTVucMKFzn+g24y9pv5 -miYdNYIk4Y+4pzHG6ZGZSHJcQ9BLui6H/nLQnqkgCb2lT5nfp7/GKdus7BdcjPGs -fcV46yL7/X0m8nDb3hkwwrDTU4mKFkMrzKpjdZBsttEmW0Aw/3y36gU= ------END RSA PRIVATE KEY----- -", - ], - "cert": [ - "-----BEGIN CERTIFICATE----- -MIIDXTCCAkWgAwIBAgIJALz8gD/gAt0OMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTgxMDIzMTgyMTQ5WhcNMTkxMDIzMTgyMTQ5WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kvC/hf5Ei1 -J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYuDy9WkFuM -ie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhsEENnH6sU -E9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2swduxJTWRI -NmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+T8emgklS -tASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABo1AwTjAdBgNVHQ4EFgQUDZBhVKdb -3BRhLIhuuE522Vsul0IwHwYDVR0jBBgwFoAUDZBhVKdb3BRhLIhuuE522Vsul0Iw -DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEABh9WWZwWLgb9/DcTxL72 -6pI96t4jiF79Q+pPefkaIIi0mE6yodWrTAsBQu9I6bNRaEcCSoiXkP2bqskD/UGg -LwUFgSrDOAA3UjdHw3QU5g2NocduG7mcFwA40TB98sOsxsUyYlzSyWzoiQWwPYwb -hek1djuWkqPXsTjlj54PTPN/SjTFmo4p5Ip6nbRf2nOREl7v0rJpGbJvXiCMYyd+ -Zv+j4mRjCGo8ysMR2HjCUGkYReLAgKyyz3M7i8vevJhKslyOmy6Txn4F0nPVumaU -DDIy4xXPW1STWfsmSYJfYW3wa0wk+pJQ3j2cTzkPQQ8gwpvM3U9DJl43uwb37v6I -7Q== ------END CERTIFICATE----- -", - ], - "key": [ - "-----BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDEBRUsUz4rdcMt -CQGLvG3SzUinsmgdgOyTNQNA0eOMyRSrmS8L+F/kSLUnqqu4mzdeqDzo2Xj553jK -dRqMCRFGJuGnQ/VIbW2A+ywgrqILuDyF5i4PL1aQW4yJ7TnXfONKfpswQArlN6DF -gBYJtoJlf8XD1sOeJpsv/O46/ix/wngQ+GwQQ2cfqxQT0fE9SBCY23VNt3SPUJ3k -9etJMvJ9U9GHSb1CFdNQe7Gyx7xdKf1TazB27ElNZEg2aF99if47uRskYjvvFivy -7nxGx/ccIwjwNMpk29AsKG++0sn1yTK7tD5Px6aCSVK0BKbdXZS2euJor8hASGBJ -3GpVGJvdAgMBAAECggEAapYo8TVCdPdP7ckb4hPP0/R0MVu9aW2VNmZ5ImH+zar5 -ZmWhQ20HF2bBupP/VB5yeTIaDLNUKO9Iqy4KBWNY1UCHKyC023FFPgFV+V98FctU -faqwGOmwtEZToRwxe48ZOISndhEc247oCPyg/x8SwIY9z0OUkwaDFBEAqWtUXxM3 -/SPpCT5ilLgxnRgVB8Fj5Z0q7ThnxNVOmVC1OSIakEj46PzmMXn1pCKLOCUmAAOQ -BnrOZuty2b8b2M/GHsktLZwojQQJmArnIBymTXQTVhaGgKSyOv1qvHLp9L1OJf0/ -Xm+/TqT6ztzhzlftcObdfQZZ5JuoEwlvyrsGFlA3MQKBgQDiQC3KYMG8ViJkWrv6 -XNAFEoAjVEKrtirGWJ66YfQ9KSJ7Zttrd1Y1V1OLtq3z4YMH39wdQ8rOD+yR8mWV -6Tnsxma6yJXAH8uan8iVbxjIZKF1hnvNCxUoxYmWOmTLcEQMzmxvTzAiR+s6R6Uj -9LgGqppt30nM4wnOhOJU6UxqbwKBgQDdy03KidbPZuycJSy1C9AIt0jlrxDsYm+U -fZrB6mHEZcgoZS5GbLKinQCdGcgERa05BXvJmNbfZtT5a37YEnbjsTImIhDiBP5P -nW36/9a3Vg1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz -TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV -HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY -/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX -JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 -zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ -iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml -amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 -Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW -QyvMqmN1kGy20SZbQDD/fLfqBQ== ------END PRIVATE KEY----- -", - ], - "passphrase": "webpack-dev-server", - "pfx": [ - "", - ], - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are array of strings should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): console messages 2`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 1`] = ` -{ - "ca": "", - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): https options 2`] = ` -{ - "ca": "", - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): page errors 2`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response status 2`] = `200`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are buffer should handle GET request to index route (/): response text 2`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` -{ - "ca": "", - "cert": "", - "key": [ - { - "pem": "", - }, - ], - "passphrase": "webpack-dev-server", - "pfx": [ - { - "buf": "", - }, - ], - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are buffer, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): https options 1`] = ` -{ - "ca": "", - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are paths to files should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): https options 1`] = ` -{ - "ca": "-----BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv -C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu -Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs -EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw -duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ -T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J -G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu -CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 -oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ -tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc -pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k+s7c4c5X7XDm3X0GWeSbqBMJb8q7 -BhZQNzECgYEA4kAtymDBvFYiZFq7+lzQBRKAI1RCq7YqxlieumH0PSkie2bba3dW -NVdTi7at8+GDB9/cHUPKzg/skfJllek57MZmusiVwB/Lmp/IlW8YyGShdYZ7zQsV -KMWJljpky3BEDM5sb08wIkfrOkelI/S4Bqqabd9JzOMJzoTiVOlMam8CgYEA3ctN -yonWz2bsnCUstQvQCLdI5a8Q7GJvlH2awephxGXIKGUuRmyyop0AnRnIBEWtOQV7 -yZjW32bU+Wt+2BJ247EyJiIQ4gT+T51t+v/Wt1YNbL3dSj9ttOvwYd4H2W4E7EIO -GKIF4I39FM7r8NfG7YE7S1aVcnrqs01N3nhd9HMCgYEAjepbzpmqbAxLPk97oase -AFB+d6qetz5ozklAJwDSRprKukTmVR5hwMup5/UKX/OQURwl4WVojKCIb3NwLPxC -DTbVsUuoQv6uo6qeEr3A+dHFRQa6GP9eolhl2Ql/t+wPg0jn01oEgzxBXCkceNVD -qUrR2yE4FYBD4nqPzVsZR5kCgYEA1yTi7NkQeldIpZ6Z43T18753A/Xx4JsLyWqd -uAT3mV9x7V1Yqg++qGbLtZjQoPRFt85N6ZxMsqA5b0iK3mXq1auJDdx1rAlT9z6q -9JM/YNAkbZsvEVq9vIYxw31w98T1GYhpzBM+yDhzir+9tv5YhQKa1dXDWi1JhWwz -YN45pWkCgYEAxuVsJ4D4Th5o050ppWpnxM/WuMhIUKqaoFTVucMKFzn+g24y9pv5 -miYdNYIk4Y+4pzHG6ZGZSHJcQ9BLui6H/nLQnqkgCb2lT5nfp7/GKdus7BdcjPGs -fcV46yL7/X0m8nDb3hkwwrDTU4mKFkMrzKpjdZBsttEmW0Aw/3y36gU= ------END RSA PRIVATE KEY----- -", - "cert": "-----BEGIN CERTIFICATE----- -MIIDXTCCAkWgAwIBAgIJALz8gD/gAt0OMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTgxMDIzMTgyMTQ5WhcNMTkxMDIzMTgyMTQ5WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kvC/hf5Ei1 -J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYuDy9WkFuM -ie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhsEENnH6sU -E9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2swduxJTWRI -NmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+T8emgklS -tASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABo1AwTjAdBgNVHQ4EFgQUDZBhVKdb -3BRhLIhuuE522Vsul0IwHwYDVR0jBBgwFoAUDZBhVKdb3BRhLIhuuE522Vsul0Iw -DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEABh9WWZwWLgb9/DcTxL72 -6pI96t4jiF79Q+pPefkaIIi0mE6yodWrTAsBQu9I6bNRaEcCSoiXkP2bqskD/UGg -LwUFgSrDOAA3UjdHw3QU5g2NocduG7mcFwA40TB98sOsxsUyYlzSyWzoiQWwPYwb -hek1djuWkqPXsTjlj54PTPN/SjTFmo4p5Ip6nbRf2nOREl7v0rJpGbJvXiCMYyd+ -Zv+j4mRjCGo8ysMR2HjCUGkYReLAgKyyz3M7i8vevJhKslyOmy6Txn4F0nPVumaU -DDIy4xXPW1STWfsmSYJfYW3wa0wk+pJQ3j2cTzkPQQ8gwpvM3U9DJl43uwb37v6I -7Q== ------END CERTIFICATE----- -", - "key": "-----BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDEBRUsUz4rdcMt -CQGLvG3SzUinsmgdgOyTNQNA0eOMyRSrmS8L+F/kSLUnqqu4mzdeqDzo2Xj553jK -dRqMCRFGJuGnQ/VIbW2A+ywgrqILuDyF5i4PL1aQW4yJ7TnXfONKfpswQArlN6DF -gBYJtoJlf8XD1sOeJpsv/O46/ix/wngQ+GwQQ2cfqxQT0fE9SBCY23VNt3SPUJ3k -9etJMvJ9U9GHSb1CFdNQe7Gyx7xdKf1TazB27ElNZEg2aF99if47uRskYjvvFivy -7nxGx/ccIwjwNMpk29AsKG++0sn1yTK7tD5Px6aCSVK0BKbdXZS2euJor8hASGBJ -3GpVGJvdAgMBAAECggEAapYo8TVCdPdP7ckb4hPP0/R0MVu9aW2VNmZ5ImH+zar5 -ZmWhQ20HF2bBupP/VB5yeTIaDLNUKO9Iqy4KBWNY1UCHKyC023FFPgFV+V98FctU -faqwGOmwtEZToRwxe48ZOISndhEc247oCPyg/x8SwIY9z0OUkwaDFBEAqWtUXxM3 -/SPpCT5ilLgxnRgVB8Fj5Z0q7ThnxNVOmVC1OSIakEj46PzmMXn1pCKLOCUmAAOQ -BnrOZuty2b8b2M/GHsktLZwojQQJmArnIBymTXQTVhaGgKSyOv1qvHLp9L1OJf0/ -Xm+/TqT6ztzhzlftcObdfQZZ5JuoEwlvyrsGFlA3MQKBgQDiQC3KYMG8ViJkWrv6 -XNAFEoAjVEKrtirGWJ66YfQ9KSJ7Zttrd1Y1V1OLtq3z4YMH39wdQ8rOD+yR8mWV -6Tnsxma6yJXAH8uan8iVbxjIZKF1hnvNCxUoxYmWOmTLcEQMzmxvTzAiR+s6R6Uj -9LgGqppt30nM4wnOhOJU6UxqbwKBgQDdy03KidbPZuycJSy1C9AIt0jlrxDsYm+U -fZrB6mHEZcgoZS5GbLKinQCdGcgERa05BXvJmNbfZtT5a37YEnbjsTImIhDiBP5P -nW36/9a3Vg1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz -TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV -HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY -/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX -JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 -zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ -iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml -amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 -Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW -QyvMqmN1kGy20SZbQDD/fLfqBQ== ------END PRIVATE KEY----- -", - "passphrase": "webpack-dev-server", - "pfx": "", - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are strings should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): https options 1`] = ` -{ - "ca": "-----BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv -C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu -Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs -EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw -duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ -T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J -G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu -CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 -oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ -tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc -pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k+s7c4c5X7XDm3X0GWeSbqBMJb8q7 -BhZQNzECgYEA4kAtymDBvFYiZFq7+lzQBRKAI1RCq7YqxlieumH0PSkie2bba3dW -NVdTi7at8+GDB9/cHUPKzg/skfJllek57MZmusiVwB/Lmp/IlW8YyGShdYZ7zQsV -KMWJljpky3BEDM5sb08wIkfrOkelI/S4Bqqabd9JzOMJzoTiVOlMam8CgYEA3ctN -yonWz2bsnCUstQvQCLdI5a8Q7GJvlH2awephxGXIKGUuRmyyop0AnRnIBEWtOQV7 -yZjW32bU+Wt+2BJ247EyJiIQ4gT+T51t+v/Wt1YNbL3dSj9ttOvwYd4H2W4E7EIO -GKIF4I39FM7r8NfG7YE7S1aVcnrqs01N3nhd9HMCgYEAjepbzpmqbAxLPk97oase -AFB+d6qetz5ozklAJwDSRprKukTmVR5hwMup5/UKX/OQURwl4WVojKCIb3NwLPxC -DTbVsUuoQv6uo6qeEr3A+dHFRQa6GP9eolhl2Ql/t+wPg0jn01oEgzxBXCkceNVD -qUrR2yE4FYBD4nqPzVsZR5kCgYEA1yTi7NkQeldIpZ6Z43T18753A/Xx4JsLyWqd -uAT3mV9x7V1Yqg++qGbLtZjQoPRFt85N6ZxMsqA5b0iK3mXq1auJDdx1rAlT9z6q -9JM/YNAkbZsvEVq9vIYxw31w98T1GYhpzBM+yDhzir+9tv5YhQKa1dXDWi1JhWwz -YN45pWkCgYEAxuVsJ4D4Th5o050ppWpnxM/WuMhIUKqaoFTVucMKFzn+g24y9pv5 -miYdNYIk4Y+4pzHG6ZGZSHJcQ9BLui6H/nLQnqkgCb2lT5nfp7/GKdus7BdcjPGs -fcV46yL7/X0m8nDb3hkwwrDTU4mKFkMrzKpjdZBsttEmW0Aw/3y36gU= ------END RSA PRIVATE KEY----- -", - "cert": "-----BEGIN CERTIFICATE----- -MIIDXTCCAkWgAwIBAgIJALz8gD/gAt0OMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTgxMDIzMTgyMTQ5WhcNMTkxMDIzMTgyMTQ5WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kvC/hf5Ei1 -J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYuDy9WkFuM -ie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhsEENnH6sU -E9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2swduxJTWRI -NmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+T8emgklS -tASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABo1AwTjAdBgNVHQ4EFgQUDZBhVKdb -3BRhLIhuuE522Vsul0IwHwYDVR0jBBgwFoAUDZBhVKdb3BRhLIhuuE522Vsul0Iw -DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEABh9WWZwWLgb9/DcTxL72 -6pI96t4jiF79Q+pPefkaIIi0mE6yodWrTAsBQu9I6bNRaEcCSoiXkP2bqskD/UGg -LwUFgSrDOAA3UjdHw3QU5g2NocduG7mcFwA40TB98sOsxsUyYlzSyWzoiQWwPYwb -hek1djuWkqPXsTjlj54PTPN/SjTFmo4p5Ip6nbRf2nOREl7v0rJpGbJvXiCMYyd+ -Zv+j4mRjCGo8ysMR2HjCUGkYReLAgKyyz3M7i8vevJhKslyOmy6Txn4F0nPVumaU -DDIy4xXPW1STWfsmSYJfYW3wa0wk+pJQ3j2cTzkPQQ8gwpvM3U9DJl43uwb37v6I -7Q== ------END CERTIFICATE----- -", - "key": [ - { - "pem": "-----BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDEBRUsUz4rdcMt -CQGLvG3SzUinsmgdgOyTNQNA0eOMyRSrmS8L+F/kSLUnqqu4mzdeqDzo2Xj553jK -dRqMCRFGJuGnQ/VIbW2A+ywgrqILuDyF5i4PL1aQW4yJ7TnXfONKfpswQArlN6DF -gBYJtoJlf8XD1sOeJpsv/O46/ix/wngQ+GwQQ2cfqxQT0fE9SBCY23VNt3SPUJ3k -9etJMvJ9U9GHSb1CFdNQe7Gyx7xdKf1TazB27ElNZEg2aF99if47uRskYjvvFivy -7nxGx/ccIwjwNMpk29AsKG++0sn1yTK7tD5Px6aCSVK0BKbdXZS2euJor8hASGBJ -3GpVGJvdAgMBAAECggEAapYo8TVCdPdP7ckb4hPP0/R0MVu9aW2VNmZ5ImH+zar5 -ZmWhQ20HF2bBupP/VB5yeTIaDLNUKO9Iqy4KBWNY1UCHKyC023FFPgFV+V98FctU -faqwGOmwtEZToRwxe48ZOISndhEc247oCPyg/x8SwIY9z0OUkwaDFBEAqWtUXxM3 -/SPpCT5ilLgxnRgVB8Fj5Z0q7ThnxNVOmVC1OSIakEj46PzmMXn1pCKLOCUmAAOQ -BnrOZuty2b8b2M/GHsktLZwojQQJmArnIBymTXQTVhaGgKSyOv1qvHLp9L1OJf0/ -Xm+/TqT6ztzhzlftcObdfQZZ5JuoEwlvyrsGFlA3MQKBgQDiQC3KYMG8ViJkWrv6 -XNAFEoAjVEKrtirGWJ66YfQ9KSJ7Zttrd1Y1V1OLtq3z4YMH39wdQ8rOD+yR8mWV -6Tnsxma6yJXAH8uan8iVbxjIZKF1hnvNCxUoxYmWOmTLcEQMzmxvTzAiR+s6R6Uj -9LgGqppt30nM4wnOhOJU6UxqbwKBgQDdy03KidbPZuycJSy1C9AIt0jlrxDsYm+U -fZrB6mHEZcgoZS5GbLKinQCdGcgERa05BXvJmNbfZtT5a37YEnbjsTImIhDiBP5P -nW36/9a3Vg1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz -TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV -HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY -/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX -JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 -zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ -iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml -amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 -Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW -QyvMqmN1kGy20SZbQDD/fLfqBQ== ------END PRIVATE KEY----- -", - }, - ], - "passphrase": "webpack-dev-server", - "pfx": [ - { - "buf": "", - }, - ], - "requestCert": false, -} -`; - -exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object ca, pfx, key and cert are strings, key and pfx are objects should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object custom server with options should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object custom server with options should handle GET request to index route (/): http options 1`] = ` -{ - "maxHeaderSize": 16384, -} -`; - -exports[`server option as object custom server with options should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object custom server with options should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object custom server with options should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object should support the "requestCert" option should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object should support the "requestCert" option should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as object should support the "requestCert" option should pass options to the 'https.createServer' method: https options 1`] = ` -{ - "cert": "", - "key": "", - "passphrase": "webpack-dev-server", - "pfx": "", - "requestCert": true, -} -`; - -exports[`server option as object spdy server with options should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as object spdy server with options should handle GET request to index route (/): https options 1`] = ` -{ - "ca": [ - "", - ], - "cert": [ - "", - ], - "key": [ - "", - ], - "passphrase": "webpack-dev-server", - "pfx": [ - "", - ], - "requestCert": false, - "spdy": { - "protocols": [ - "h2", - "http/1.1", - ], - }, -} -`; - -exports[`server option as object spdy server with options should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as object spdy server with options should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as object spdy server with options should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as string custom-http should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as string custom-http should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as string custom-http should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as string custom-http should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as string http should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as string http should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as string http should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as string http should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as string https should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as string https should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as string https should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as string https should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; - -exports[`server option as string spdy should handle GET request to index route (/): console messages 1`] = `[]`; - -exports[`server option as string spdy should handle GET request to index route (/): page errors 1`] = `[]`; - -exports[`server option as string spdy should handle GET request to index route (/): response status 1`] = `200`; - -exports[`server option as string spdy should handle GET request to index route (/): response text 1`] = ` -"Heyo. -" -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/setup-exit-signals.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/setup-exit-signals.test.js.snap.webpack5 deleted file mode 100644 index 79ceb12e6ed..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/setup-exit-signals.test.js.snap.webpack5 +++ /dev/null @@ -1,25 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`setupExitSignals option should handle 'SIGINT' and 'SIGTERM' signals should close and exit on SIGINT: 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[`setupExitSignals option should handle 'SIGINT' and 'SIGTERM' signals should close and exit on SIGINT: page errors 1`] = `[]`; - -exports[`setupExitSignals option should handle 'SIGINT' and 'SIGTERM' signals should close and exit on SIGINT: response status 1`] = `200`; - -exports[`setupExitSignals option should handle 'SIGINT' and 'SIGTERM' signals should close and exit on SIGTERM: 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[`setupExitSignals option should handle 'SIGINT' and 'SIGTERM' signals should close and exit on SIGTERM: page errors 1`] = `[]`; - -exports[`setupExitSignals option should handle 'SIGINT' and 'SIGTERM' signals should close and exit on SIGTERM: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/setup-middlewares.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/setup-middlewares.test.js.snap.webpack5 deleted file mode 100644 index c22699072a3..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/setup-middlewares.test.js.snap.webpack5 +++ /dev/null @@ -1,39 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: console messages 1`] = `[]`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: page errors 1`] = `[]`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response headers content-type 2`] = `"text/html; charset=utf-8"`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response headers content-type 3`] = `"text/html; charset=utf-8"`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response headers content-type 4`] = `"text/html; charset=utf-8"`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response status 1`] = `200`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response status 2`] = `200`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response status 3`] = `200`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response status 4`] = `200`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response text 1`] = `"setup-middlewares option GET"`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response text 2`] = `"Hello World with path!"`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response text 3`] = `"Hello World without path!"`; - -exports[`setupMiddlewares option should handle GET request to /setup-middleware/some/path route: response text 4`] = `"Hello World as function!"`; - -exports[`setupMiddlewares option should handle POST request to /setup-middleware/some/path route: console messages 1`] = `[]`; - -exports[`setupMiddlewares option should handle POST request to /setup-middleware/some/path route: page errors 1`] = `[]`; - -exports[`setupMiddlewares option should handle POST request to /setup-middleware/some/path route: response headers content-type 1`] = `"text/html; charset=utf-8"`; - -exports[`setupMiddlewares option should handle POST request to /setup-middleware/some/path route: response status 1`] = `200`; - -exports[`setupMiddlewares option should handle POST request to /setup-middleware/some/path route: response text 1`] = `"setup-middlewares option POST"`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/static-directory.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/static-directory.test.js.snap.webpack5 deleted file mode 100644 index 174cb1de42e..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/static-directory.test.js.snap.webpack5 +++ /dev/null @@ -1,149 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`static.directory option defaults to PWD should handle request to /index.html: console messages 1`] = `[]`; - -exports[`static.directory option defaults to PWD should handle request to /index.html: page errors 1`] = `[]`; - -exports[`static.directory option defaults to PWD should handle request to /index.html: response status 1`] = `200`; - -exports[`static.directory option defaults to PWD should handle request to /index.html: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.directory option disabled should not handle request to /other.html (404): console messages 1`] = ` -[ - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`static.directory option disabled should not handle request to /other.html (404): page errors 1`] = `[]`; - -exports[`static.directory option disabled should not handle request to /other.html (404): response status 1`] = `404`; - -exports[`static.directory option disabled should not handle request to /other.html (404): response text 1`] = ` -" - - - -Error - - -
Cannot GET /index.html
- - -" -`; - -exports[`static.directory option test listing files in folders without index.html using the default static.serveIndex option (true) should list the files inside the assets folder (200): console messages 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the default static.serveIndex option (true) should list the files inside the assets folder (200): page errors 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the default static.serveIndex option (true) should list the files inside the assets folder (200): response status 1`] = `200`; - -exports[`static.directory option test listing files in folders without index.html using the default static.serveIndex option (true) should show Heyo. because bar has index.html inside it (200): console messages 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the default static.serveIndex option (true) should show Heyo. because bar has index.html inside it (200): page errors 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the default static.serveIndex option (true) should show Heyo. because bar has index.html inside it (200): response status 1`] = `200`; - -exports[`static.directory option test listing files in folders without index.html using the default static.serveIndex option (true) should show Heyo. because bar has index.html inside it (200): response text 1`] = ` -"Heyo -" -`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should not list the files inside the assets folder (404): console messages 1`] = ` -[ - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should not list the files inside the assets folder (404): page errors 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should not list the files inside the assets folder (404): response status 1`] = `404`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should not list the files inside the assets folder (404): response text 1`] = ` -" - - - -Error - - -
Cannot GET /assets/
- - -" -`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): console messages 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): page errors 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): response status 1`] = `200`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): response text 1`] = ` -"Heyo -" -`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: true should list the files inside the assets folder (200): console messages 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: true should list the files inside the assets folder (200): page errors 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: true should list the files inside the assets folder (200): response status 1`] = `200`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): console messages 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): page errors 1`] = `[]`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): response status 1`] = `200`; - -exports[`static.directory option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): response text 1`] = ` -"Heyo -" -`; - -exports[`static.directory option to directory should handle request to index route: console messages 1`] = `[]`; - -exports[`static.directory option to directory should handle request to index route: page errors 1`] = `[]`; - -exports[`static.directory option to directory should handle request to index route: response status 1`] = `200`; - -exports[`static.directory option to directory should handle request to index route: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.directory option to directory should handle request to other file: console messages 1`] = `[]`; - -exports[`static.directory option to directory should handle request to other file: page errors 1`] = `[]`; - -exports[`static.directory option to directory should handle request to other file: response status 1`] = `200`; - -exports[`static.directory option to directory should handle request to other file: response text 1`] = ` -"Other html -" -`; - -exports[`static.directory option to multiple directories should handle request first directory: console messages 1`] = `[]`; - -exports[`static.directory option to multiple directories should handle request first directory: page errors 1`] = `[]`; - -exports[`static.directory option to multiple directories should handle request first directory: response status 1`] = `200`; - -exports[`static.directory option to multiple directories should handle request first directory: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.directory option to multiple directories should handle request to second directory: console messages 1`] = `[]`; - -exports[`static.directory option to multiple directories should handle request to second directory: page errors 1`] = `[]`; - -exports[`static.directory option to multiple directories should handle request to second directory: response status 1`] = `200`; - -exports[`static.directory option to multiple directories should handle request to second directory: response text 1`] = ` -"Foo! -" -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/static-public-path.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/static-public-path.test.js.snap.webpack5 deleted file mode 100644 index 3140335f472..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/static-public-path.test.js.snap.webpack5 +++ /dev/null @@ -1,262 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`static.publicPath option Content type should handle request to example.txt: console messages 1`] = `[]`; - -exports[`static.publicPath option Content type should handle request to example.txt: page errors 1`] = `[]`; - -exports[`static.publicPath option Content type should handle request to example.txt: response header content-type 1`] = `"text/plain; charset=UTF-8"`; - -exports[`static.publicPath option Content type should handle request to example.txt: response status 1`] = `200`; - -exports[`static.publicPath option defaults to CWD should handle request to page: console messages 1`] = `[]`; - -exports[`static.publicPath option defaults to CWD should handle request to page: page errors 1`] = `[]`; - -exports[`static.publicPath option defaults to CWD should handle request to page: response status 1`] = `200`; - -exports[`static.publicPath option defaults to CWD should handle request to page: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the /foo route of second path: console messages 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the /foo route of second path: page errors 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the /foo route of second path: response status 1`] = `200`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the /foo route of second path: response text 1`] = ` -"Foo! -" -`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the index of first path: console messages 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the index of first path: page errors 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the index of first path: response status 1`] = `200`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the index of first path: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the other file of first path: console messages 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the other file of first path: page errors 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the other file of first path: response status 1`] = `200`; - -exports[`static.publicPath option multiple static.publicPath entries should handle request to the other file of first path: response text 1`] = ` -"Other html -" -`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of first path: console messages 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of first path: page errors 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of first path: response status 1`] = `200`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of first path: response text 1`] = ` -"Foo! -" -`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of second path: console messages 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of second path: page errors 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of second path: response status 1`] = `200`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the /foo route of second path: response text 1`] = ` -"Foo! -" -`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the index of first path: console messages 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the index of first path: page errors 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the index of first path: response status 1`] = `200`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the index of first path: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the other file of first path: console messages 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the other file of first path: page errors 1`] = `[]`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the other file of first path: response status 1`] = `200`; - -exports[`static.publicPath option multiple static.publicPath entries with publicPath array should handle request to the other file of first path: response text 1`] = ` -"Other html -" -`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should handle GET request: console messages 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should handle GET request: page errors 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should handle GET request: response status 1`] = `200`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should handle HEAD request: console messages 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should handle HEAD request: page errors 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should handle HEAD request: response status 1`] = `200`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle DELETE request: console messages 1`] = ` -[ - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle DELETE request: page errors 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle DELETE request: response status 1`] = `404`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle PATCH request: console messages 1`] = ` -[ - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle PATCH request: page errors 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle PATCH request: response status 1`] = `404`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle POST request: console messages 1`] = ` -[ - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle POST request: page errors 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle POST request: response status 1`] = `404`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle PUT request: console messages 1`] = ` -[ - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle PUT request: page errors 1`] = `[]`; - -exports[`static.publicPath option should ignore methods other than GET and HEAD should not handle PUT request: response status 1`] = `404`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex default (true) should list the files inside the assets folder (200): console messages 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex default (true) should list the files inside the assets folder (200): page errors 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex default (true) should list the files inside the assets folder (200): response status 1`] = `200`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex default (true) should show Heyo. because bar has index.html inside it (200): console messages 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex default (true) should show Heyo. because bar has index.html inside it (200): page errors 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex default (true) should show Heyo. because bar has index.html inside it (200): response status 1`] = `200`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex default (true) should show Heyo. because bar has index.html inside it (200): response text 1`] = ` -"Heyo -" -`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): console messages 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): page errors 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): response status 1`] = `200`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false should show Heyo. because bar has index.html inside it (200): response text 1`] = ` -"Heyo -" -`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false shouldn't list the files inside the assets folder (404): console messages 1`] = ` -[ - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false shouldn't list the files inside the assets folder (404): page errors 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false shouldn't list the files inside the assets folder (404): response status 1`] = `404`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: false shouldn't list the files inside the assets folder (404): response text 1`] = ` -" - - - -Error - - -
Cannot GET /serve-content-at-this-url/assets/
- - -" -`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: true should list the files inside the assets folder (200): console messages 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: true should list the files inside the assets folder (200): page errors 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: true should list the files inside the assets folder (200): response status 1`] = `200`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): console messages 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): page errors 1`] = `[]`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): response status 1`] = `200`; - -exports[`static.publicPath option test listing files in folders without index.html using the option static.serveIndex: true should show Heyo. because bar has index.html inside it (200): response text 1`] = ` -"Heyo -" -`; - -exports[`static.publicPath option to directory should handle request to index: console messages 1`] = `[]`; - -exports[`static.publicPath option to directory should handle request to index: page errors 1`] = `[]`; - -exports[`static.publicPath option to directory should handle request to index: response status 1`] = `200`; - -exports[`static.publicPath option to directory should handle request to index: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.publicPath option to directory should handle request to other file: console messages 1`] = `[]`; - -exports[`static.publicPath option to directory should handle request to other file: page errors 1`] = `[]`; - -exports[`static.publicPath option to directory should handle request to other file: response status 1`] = `200`; - -exports[`static.publicPath option to directory should handle request to other file: response text 1`] = ` -"Other html -" -`; - -exports[`static.publicPath option to multiple directories should handle request to first directory: console messages 1`] = `[]`; - -exports[`static.publicPath option to multiple directories should handle request to first directory: page errors 1`] = `[]`; - -exports[`static.publicPath option to multiple directories should handle request to first directory: response status 1`] = `200`; - -exports[`static.publicPath option to multiple directories should handle request to first directory: response text 1`] = ` -"Heyo. -" -`; - -exports[`static.publicPath option to multiple directories should handle request to second directory: console messages 1`] = `[]`; - -exports[`static.publicPath option to multiple directories should handle request to second directory: page errors 1`] = `[]`; - -exports[`static.publicPath option to multiple directories should handle request to second directory: response status 1`] = `200`; - -exports[`static.publicPath option to multiple directories should handle request to second directory: response text 1`] = ` -"Foo! -" -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/stats.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/stats.test.js.snap.webpack5 deleted file mode 100644 index 7d40670ec9e..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/stats.test.js.snap.webpack5 +++ /dev/null @@ -1,57 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`stats should work and respect the "ignoreWarnings" option 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[`stats should work using "{ assets: false }" value for the "stats" option 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[`stats should work using "{}" value for the "stats" option 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[`stats should work using "errors-only" value for the "stats" option 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[`stats should work using "false" value for the "stats" option 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[`stats should work using "undefined" value for the "stats" option 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[`stats should work when "stats" is not specified 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.", -] -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/target.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/target.test.js.snap.webpack5 deleted file mode 100644 index 877b6a1e767..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/target.test.js.snap.webpack5 +++ /dev/null @@ -1,94 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`target should work using "async-node" target: console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "Hey.", -] -`; - -exports[`target should work using "browserslist:defaults" target: 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[`target should work using "electron-main" target: console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "Hey.", -] -`; - -exports[`target should work using "electron-preload" target: 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[`target should work using "electron-renderer" target: console messages 1`] = `[]`; - -exports[`target should work using "es5" target: console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "Hey.", -] -`; - -exports[`target should work using "false" target: console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "Hey.", -] -`; - -exports[`target should work using "node" target: console messages 1`] = ` -[ - "[HMR] Waiting for update signal from WDS...", - "Hey.", -] -`; - -exports[`target should work using "node-webkit" target: 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[`target should work using "nwjs" target: 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[`target should work using "web" target: 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[`target should work using "web,es5" target: 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[`target should work using "webworker" target: 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.", -] -`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/watch-files.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/watch-files.test.js.snap.webpack5 deleted file mode 100644 index 5c63e7b714d..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/watch-files.test.js.snap.webpack5 +++ /dev/null @@ -1,311 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`watchFiles option should not crash if file doesn't exist should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should not crash if file doesn't exist should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should not crash if file doesn't exist should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with array config should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with array config should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with array config should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with object with multiple paths should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with object with multiple paths should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with object with multiple paths should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with object with single path should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with object with single path should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with object with single path should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"interval":400,"poll":200} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": 400, - "persistent": true, - "usePolling": true, -} -`; - -exports[`watchFiles option should work with options {"interval":400,"poll":200} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"interval":400,"poll":200} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"interval":400,"poll":200} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"poll":200} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": 200, - "persistent": true, - "usePolling": true, -} -`; - -exports[`watchFiles option should work with options {"poll":200} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"poll":200} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"poll":200} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"poll":true} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": undefined, - "persistent": true, - "usePolling": true, -} -`; - -exports[`watchFiles option should work with options {"poll":true} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"poll":true} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"poll":true} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"usePolling":false,"interval":200,"poll":400} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": 200, - "persistent": true, - "usePolling": false, -} -`; - -exports[`watchFiles option should work with options {"usePolling":false,"interval":200,"poll":400} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"usePolling":false,"interval":200,"poll":400} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"usePolling":false,"interval":200,"poll":400} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":200} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": 200, - "persistent": true, - "usePolling": false, -} -`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":200} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":200} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":200} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":true} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": undefined, - "persistent": true, - "usePolling": false, -} -`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":true} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":true} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"usePolling":false,"poll":true} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"usePolling":false} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": undefined, - "persistent": true, - "usePolling": false, -} -`; - -exports[`watchFiles option should work with options {"usePolling":false} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"usePolling":false} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"usePolling":false} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"usePolling":true,"interval":200,"poll":400} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": 200, - "persistent": true, - "usePolling": true, -} -`; - -exports[`watchFiles option should work with options {"usePolling":true,"interval":200,"poll":400} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"usePolling":true,"interval":200,"poll":400} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"usePolling":true,"interval":200,"poll":400} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"usePolling":true,"poll":200} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": 200, - "persistent": true, - "usePolling": true, -} -`; - -exports[`watchFiles option should work with options {"usePolling":true,"poll":200} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"usePolling":true,"poll":200} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"usePolling":true,"poll":200} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with options {"usePolling":true} should reload when file content is changed 1`] = ` -{ - "alwaysStat": true, - "atomic": false, - "followSymlinks": false, - "ignoreInitial": true, - "ignorePermissionErrors": true, - "ignored": undefined, - "interval": undefined, - "persistent": true, - "usePolling": true, -} -`; - -exports[`watchFiles option should work with options {"usePolling":true} should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with options {"usePolling":true} should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with options {"usePolling":true} should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with string and glob should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with string and glob should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with string and glob should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with string and path to directory should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with string and path to directory should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with string and path to directory should reload when file content is changed: response status 1`] = `200`; - -exports[`watchFiles option should work with string and path to file should reload when file content is changed: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`watchFiles option should work with string and path to file should reload when file content is changed: page errors 1`] = `[]`; - -exports[`watchFiles option should work with string and path to file should reload when file content is changed: response status 1`] = `200`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-communication.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-communication.test.js.snap.webpack5 deleted file mode 100644 index 6937debfff0..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-communication.test.js.snap.webpack5 +++ /dev/null @@ -1,81 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`web socket communication should work and close web socket client connection when web socket server closed ("sockjs"): 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.", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`web socket communication should work and close web socket client connection when web socket server closed ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket communication should work and close web socket client connection when web socket server closed ("ws"): 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.", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", -] -`; - -exports[`web socket communication should work and close web socket client connection when web socket server closed ("ws"): page errors 1`] = `[]`; - -exports[`web socket communication should work and reconnect when the connection is lost ("sockjs"): 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.", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "Failed to load resource: the server responded with a status of 404 (Not Found)", - "[HMR] Cannot find update. Need to do a full reload!", - "[HMR] (Probably because of restarting the webpack-dev-server)", - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`web socket communication should work and reconnect when the connection is lost ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket communication should work and reconnect when the connection is lost ("ws"): 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.", - "[webpack-dev-server] Disconnected!", - "[webpack-dev-server] Trying to reconnect...", - "[webpack-dev-server] App hot update...", - "[HMR] Checking for updates on the server...", - "Failed to load resource: the server responded with a status of 404 (Not Found)", - "[HMR] Cannot find update. Need to do a full reload!", - "[HMR] (Probably because of restarting the webpack-dev-server)", - "Failed to load resource: the server responded with a status of 404 (Not Found)", -] -`; - -exports[`web socket communication should work and reconnect when the connection is lost ("ws"): page errors 1`] = `[]`; - -exports[`web socket communication should work and terminate client that is not alive ("sockjs"): 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[`web socket communication should work and terminate client that is not alive ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket communication should work and terminate client that is not alive ("ws"): 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[`web socket communication should work and terminate client that is not alive ("ws"): page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-server-url.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-server-url.test.js.snap.webpack5 deleted file mode 100644 index 68160182e3f..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-server-url.test.js.snap.webpack5 +++ /dev/null @@ -1,710 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`web socket server URL should not work and output disconnect wrong web socket URL ("sockjs"): 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.", - "Failed to load resource: net::ERR_NAME_NOT_RESOLVED", - "[webpack-dev-server] Disconnected!", -] -`; - -exports[`web socket server URL should not work and output disconnect wrong web socket URL ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should not work and output disconnect wrong web socket URL ("ws"): 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.", - "WebSocket connection to 'ws://unknown.unknown:/unknown' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED", - "[webpack-dev-server] JSHandle@object", - "[webpack-dev-server] Disconnected!", -] -`; - -exports[`web socket server URL should not work and output disconnect wrong web socket URL ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work and throw an error on invalid web socket URL ("sockjs"): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", -] -`; - -exports[`web socket server URL should work and throw an error on invalid web socket URL ("sockjs"): page errors 1`] = ` -[ - "The URL's scheme must be either 'http:' or 'https:'. 'unknown:' is not allowed.", -] -`; - -exports[`web socket server URL should work and throw an error on invalid web socket URL ("ws"): console messages 1`] = ` -[ - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.", -] -`; - -exports[`web socket server URL should work and throw an error on invalid web socket URL ("ws"): page errors 1`] = ` -[ - "SyntaxError: Failed to construct 'WebSocket': The URL's scheme must be either 'http', 'https', 'ws', or 'wss'. 'unknown' is not allowed.", -] -`; - -exports[`web socket server URL should work behind proxy, when hostnames are different and ports are different ("sockjs"): 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[`web socket server URL should work behind proxy, when hostnames are different and ports are different ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work behind proxy, when hostnames are different and ports are different ("ws"): 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[`web socket server URL should work behind proxy, when hostnames are different and ports are different ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work behind proxy, when hostnames are different and ports are same ("sockjs"): 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[`web socket server URL should work behind proxy, when hostnames are different and ports are same ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work behind proxy, when hostnames are different and ports are same ("ws"): 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[`web socket server URL should work behind proxy, when hostnames are different and ports are same ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work behind proxy, when hostnames are same and ports are different ("sockjs"): 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[`web socket server URL should work behind proxy, when hostnames are same and ports are different ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work behind proxy, when hostnames are same and ports are different ("ws"): 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[`web socket server URL should work behind proxy, when hostnames are same and ports are different ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("sockjs"): 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[`web socket server URL should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("ws"): 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[`web socket server URL should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "host" option is "local-ip" ("sockjs"): 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[`web socket server URL should work when "host" option is "local-ip" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "host" option is "local-ip" ("ws"): 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[`web socket server URL should work when "host" option is "local-ip" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "host" option is "local-ipv4" ("sockjs"): 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[`web socket server URL should work when "host" option is "local-ipv4" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "host" option is "local-ipv4" ("ws"): 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[`web socket server URL should work when "host" option is "local-ipv4" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "host" option is IPv4 ("sockjs"): 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[`web socket server URL should work when "host" option is IPv4 ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "host" option is IPv4 ("ws"): 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[`web socket server URL should work when "host" option is IPv4 ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "port" option is "auto" ("sockjs"): 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[`web socket server URL should work when "port" option is "auto" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work when "port" option is "auto" ("ws"): 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[`web socket server URL should work when "port" option is "auto" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "client.webSocketURL.*" options ("sockjs"): 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[`web socket server URL should work with "client.webSocketURL.*" options ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "client.webSocketURL.*" options ("ws"): 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[`web socket server URL should work with "client.webSocketURL.*" options ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "client.webSocketURL.port" and "webSocketServer.options.port" options as string ("sockjs"): 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[`web socket server URL should work with "client.webSocketURL.port" and "webSocketServer.options.port" options as string ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "client.webSocketURL.port" and "webSocketServer.options.port" options as string ("ws"): 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[`web socket server URL should work with "client.webSocketURL.port" and "webSocketServer.options.port" options as string ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "server: 'https'" option ("sockjs"): 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[`web socket server URL should work with "server: 'https'" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "server: 'https'" option ("ws"): 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[`web socket server URL should work with "server: 'https'" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "server: 'spdy'" option ("sockjs"): 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[`web socket server URL should work with "server: 'spdy'" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with "server: 'spdy'" option ("ws"): 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[`web socket server URL should work with "server: 'spdy'" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with default "/ws" value of the "client.webSocketURL.pathname" option ("sockjs"): 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[`web socket server URL should work with default "/ws" value of the "client.webSocketURL.pathname" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with default "/ws" value of the "client.webSocketURL.pathname" option ("ws"): 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[`web socket server URL should work with default "/ws" value of the "client.webSocketURL.pathname" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL" option as "string" ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL" option as "string" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL" option as "string" ("ws"): 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[`web socket server URL should work with the "client.webSocketURL" option as "string" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.host" option ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.host" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.host" option ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.host" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.host" option using "0.0.0.0" value ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.host" option using "0.0.0.0" value ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.host" option using "0.0.0.0" value ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.host" option using "0.0.0.0" value ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.password" option ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.password" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.password" option ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.password" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending with slash ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending with slash ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending with slash ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending with slash ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending without slash ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending without slash ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending without slash ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending without slash ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" using empty value ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" using empty value ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" using empty value ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" using empty value ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "prefix" for compatibility with "sockjs" ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "prefix" for compatibility with "sockjs" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "prefix" for compatibility with "sockjs" ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.pathname" option and the custom web socket server "prefix" for compatibility with "sockjs" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.port" option ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.port" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.port" option ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.port" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.port" option as string ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.port" option as string ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.port" option as string ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.port" option as string ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.port" option using "0" value ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.port" option using "0" value ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.port" option using "0" value ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.port" option using "0" value ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.protocol" option ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.protocol" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.protocol" option ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.protocol" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.protocol" option using "auto:" value ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.protocol" option using "auto:" value ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.protocol" option using "auto:" value ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.protocol" option using "auto:" value ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.protocol" option using "http:" value and covert to "ws:" ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.protocol" option using "http:" value and covert to "ws:" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.protocol" option using "http:" value and covert to "ws:" ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.protocol" option using "http:" value and covert to "ws:" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.username" and "client.webSocketURL.password" option ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.username" and "client.webSocketURL.password" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.username" and "client.webSocketURL.password" option ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.username" and "client.webSocketURL.password" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.username" option ("sockjs"): 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[`web socket server URL should work with the "client.webSocketURL.username" option ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the "client.webSocketURL.username" option ("ws"): 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[`web socket server URL should work with the "client.webSocketURL.username" option ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the custom web socket server "path" ("sockjs"): 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[`web socket server URL should work with the custom web socket server "path" ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the custom web socket server "path" ("ws"): 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[`web socket server URL should work with the custom web socket server "path" ("ws"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the custom web socket server "path" using empty value ("sockjs"): 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[`web socket server URL should work with the custom web socket server "path" using empty value ("sockjs"): page errors 1`] = `[]`; - -exports[`web socket server URL should work with the custom web socket server "path" using empty value ("ws"): 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[`web socket server URL should work with the custom web socket server "path" using empty value ("ws"): page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-server.test.js.snap.webpack5 b/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-server.test.js.snap.webpack5 deleted file mode 100644 index 2efd0f39195..00000000000 --- a/packages/rspack-dev-server/tests/e2e/__snapshots__/web-socket-server.test.js.snap.webpack5 +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`web socket server should work allow to disable: console messages 1`] = ` -[ - "Hey.", -] -`; - -exports[`web socket server should work allow to disable: page errors 1`] = `[]`; diff --git a/packages/rspack-dev-server/tests/e2e/allowed-hosts.test.js b/packages/rspack-dev-server/tests/e2e/allowed-hosts.test.js deleted file mode 100644 index e31c2b54cdc..00000000000 --- a/packages/rspack-dev-server/tests/e2e/allowed-hosts.test.js +++ /dev/null @@ -1,1531 +0,0 @@ -"use strict"; - -const express = require("express"); -const webpack = require("@rspack/core"); -const { createProxyMiddleware } = require("http-proxy-middleware"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const [port1, port2] = require("../helpers/ports-map")["allowed-hosts"]; - -const webSocketServers = ["ws", "sockjs"]; - -describe("allowed hosts", () => { - for (const webSocketServer of webSocketServers) { - it(`should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("host", "my-test-host"); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "host" header when "server: 'https'" is enabled ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2, - protocol: "ws" - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto", - server: "https" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("host", "my-test-host"); - }, - target: `https://${devServerHost}:${devServerPort}`, - secure: false, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should disconnect web socket client using custom hostname from web socket server with the "auto" value based on the "origin" header ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "http://my-test-origin.com/"); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using localhost to web socket server with the "auto" value ("${webSocketServer}")`, async () => { - const devServerHost = "localhost"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using "127.0.0.1" host to web socket server with the "auto" value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using "[::1] host to web socket server with the "auto" value ("${webSocketServer}")`, async () => { - const devServerHost = "::1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - target: `http://[${devServerHost}]:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://[${proxyHost}]:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using "file:" protocol to web socket server with the "auto" value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - target: `http://${devServerHost}:${devServerPort}`, - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "file:///path/to/local/file.js"); - }, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using "chrome-extension:" protocol to web socket server with the "auto" value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - target: `http://${devServerHost}:${devServerPort}`, - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "chrome-extension:///abcdef"); - }, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using custom hostname to web socket server with the "all" value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "http://my-test-origin.com/"); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using custom hostname to web socket server with the "all" value in array ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: ["all"] - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "http://my-test-origin.com/"); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using custom hostname to web socket server with the custom hostname value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "my-test-origin.com" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "http://my-test-origin.com/"); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using custom hostname to web socket server with the custom hostname value starting with dot ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: ".my-test-origin.com" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "http://my-test-origin.com/"); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using custom sub hostname to web socket server with the custom hostname value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: ".my-test-origin.com" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader( - "origin", - "http://foo.bar.baz.my-test-origin.com/" - ); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should connect web socket client using custom hostname to web socket server with the multiple custom hostname values ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: ["my-test-origin.com"] - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReqWs: proxyReq => { - proxyReq.setHeader("origin", "http://my-test-origin.com/"); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should disconnect web client using localhost to web socket server with the "auto" value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port2 - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "auto" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - // Emulation - onProxyReq: (proxyReq, req, res) => { - proxyReq.setHeader("host", "unknown"); - res.setHeader("host", devServerHost); - }, - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - const html = await page.content(); - - expect(html).toMatchSnapshot("html"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - } - - describe("check host headers", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(() => { - compiler = webpack(config); - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should always allow `localhost` if options.allowedHosts is auto", async () => { - const options = { - allowedHosts: "auto", - port: port1 - }; - - const headers = { - host: "localhost" - }; - - server = new Server(options, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port1}/main.js`, { - waitUntil: "networkidle0" - }); - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't fail"); - } - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should always allow `localhost` subdomain if options.allowedHosts is auto", async () => { - const options = { - allowedHosts: "auto", - port: port1 - }; - - const headers = { - host: "app.localhost" - }; - - server = new Server(options, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port1}/main.js`, { - waitUntil: "networkidle0" - }); - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't fail"); - } - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should always allow value from the `host` options if options.allowedHosts is auto", async () => { - const networkIP = Server.internalIPSync("v4"); - const options = { - host: networkIP, - allowedHosts: "auto", - port: port1 - }; - - const headers = { - host: networkIP - }; - - server = new Server(options, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://${networkIP}:${port1}/main.js`, { - waitUntil: "networkidle0" - }); - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't fail"); - } - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should always allow value of the `host` option from the `client.webSocketURL` option if options.allowedHosts is auto", async () => { - const options = { - allowedHosts: "auto", - port: port1, - client: { - webSocketURL: "ws://test.host:80" - } - }; - - const headers = { - host: "test.host" - }; - - server = new Server(options, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port1}/main.js`, { - waitUntil: "networkidle0" - }); - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't fail"); - } - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should always allow any host if options.allowedHosts is all", async () => { - const options = { - allowedHosts: "all", - port: port1 - }; - const headers = { - host: "bad.host" - }; - - server = new Server(options, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port1}/main.js`, { - waitUntil: "networkidle0" - }); - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't fail"); - } - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should allow hosts in allowedHosts", async () => { - const tests = ["test.host", "test2.host", "test3.host"]; - const options = { - allowedHosts: tests, - port: port1 - }; - - server = new Server(options, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port1}/main.js`, { - waitUntil: "networkidle0" - }); - - tests.forEach(test => { - const headers = { host: test }; - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't fail"); - } - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should allow hosts that pass a wildcard in allowedHosts", async () => { - const options = { - allowedHosts: [".example.com"], - port: port1 - }; - - server = new Server(options, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port1}/main.js`, { - waitUntil: "networkidle0" - }); - - const tests = [ - "www.example.com", - "subdomain.example.com", - "example.com", - "subsubcomain.subdomain.example.com", - "example.com:80", - "subdomain.example.com:80" - ]; - - tests.forEach(test => { - const headers = { host: test }; - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't fail"); - } - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/api.test.js b/packages/rspack-dev-server/tests/e2e/api.test.js deleted file mode 100644 index 730224ebf89..00000000000 --- a/packages/rspack-dev-server/tests/e2e/api.test.js +++ /dev/null @@ -1,754 +0,0 @@ -"use strict"; - -const path = require("path"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const sessionSubscribe = require("../helpers/session-subscribe"); -const port = require("../helpers/ports-map").api; - -describe("API", () => { - describe("WEBPACK_SERVE environment variable", () => { - const OLD_ENV = process.env; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - // this is important - it clears the cache - jest.resetModules(); - - process.env = { ...OLD_ENV }; - - delete process.env.WEBPACK_SERVE; - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - process.env = OLD_ENV; - }); - - it("should be present", async () => { - expect(process.env.WEBPACK_SERVE).toBeUndefined(); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const { - RspackDevServer: WebpackDevServer - } = require("@rspack/dev-server"); - - const compiler = webpack(config); - server = new WebpackDevServer({ port }, compiler); - - await server.start(); - - expect(process.env.WEBPACK_SERVE).toBe("true"); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("latest async API", () => { - it(`should work with async API`, async () => { - const compiler = webpack(config); - const server = new Server({ port }, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with callback API`, async () => { - const compiler = webpack(config); - const server = new Server({ port }, compiler); - - await new Promise(resolve => { - server.startCallback(() => { - resolve(); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await new Promise(resolve => { - server.stopCallback(() => { - resolve(); - }); - }); - } - }); - - it(`should catch errors within startCallback`, async () => { - const compiler = webpack(config); - const server = new Server( - { port, static: "https://absolute-url.com/somewhere" }, - compiler - ); - - await new Promise(resolve => { - server.startCallback(err => { - expect(err.message).toEqual( - "Using a URL as static.directory is not supported" - ); - resolve(); - }); - }); - - await new Promise(resolve => { - server.stopCallback(() => { - resolve(); - }); - }); - }); - - it(`should work when using configured manually`, async () => { - const compiler = webpack({ - ...config, - entry: [ - "@rspack/core/hot/dev-server.js", - `@rspack/dev-server/client/index.js?hot=true&live-reload=true"`, - path.resolve(__dirname, "../fixtures/client-config/foo.js") - ], - plugins: [...config.plugins, new webpack.HotModuleReplacementPlugin()] - }); - const server = new Server({ port, hot: false, client: false }, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work and allow to rerun dev server multiple times`, async () => { - const compiler = webpack(config); - const server = new Server({ port }, compiler); - - await server.start(); - - const { page: firstPage, browser } = await runBrowser(); - - try { - const firstPageErrors = []; - const firstConsoleMessages = []; - - firstPage - .on("console", message => { - firstConsoleMessages.push(message); - }) - .on("pageerror", error => { - firstPageErrors.push(error); - }); - - await firstPage.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - firstConsoleMessages.map(message => message.text()) - ).toMatchSnapshot("console messages"); - expect(firstPageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await server.stop(); - } - - await server.start(); - - const secondPage = await runBrowser.runPage(browser); - - try { - // const secondPageErrors = []; - // const secondConsoleMessages = []; - // secondPage - // .on("console", (message) => { - // secondConsoleMessages.push(message); - // }) - // .on("pageerror", (error) => { - // secondPageErrors.push(error); - // }); - // await secondPage.goto(`http://127.0.0.1:${port}/`, { - // waitUntil: "networkidle0", - // }); - // expect( - // secondConsoleMessages.map((message) => message.text()), - // ).toMatchSnapshot("console messages"); - // expect(secondPageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - }); - - describe("Invalidate callback", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - server = new Server({ port, static: false }, compiler); - - await server.start(); - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should use the default `noop` callback when invalidate is called without any callback", async () => { - const callback = jest.fn(); - - server.invalidate(); - server.middleware.context.callbacks[0] = callback; - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(callback).toHaveBeenCalledTimes(1); - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should use the provided `callback` function", async () => { - const callback = jest.fn(); - - server.invalidate(callback); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(callback).toHaveBeenCalledTimes(1); - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("Server.getFreePort", () => { - let dummyServers = []; - let devServerPort; - - afterEach(() => { - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - delete process.env.WEBPACK_DEV_SERVER_PORT_RETRY; - - return dummyServers - .reduce( - (p, server) => - p.then( - () => - new Promise(resolve => { - server.stopCallback(() => { - resolve(); - }); - }) - ), - Promise.resolve() - ) - .then(() => { - dummyServers = []; - }); - }); - - function createDummyServers(n) { - process.env.WEBPACK_DEV_SERVER_BASE_PORT = 60000; - - return (Array.isArray(n) ? n : [...new Array(n)]).reduce( - (p, _, i) => - p.then( - () => - new Promise(resolve => { - devServerPort = 60000 + i; - const compiler = webpack(config); - const server = new Server( - { port: devServerPort, host: "0.0.0.0" }, - compiler - ); - - dummyServers.push(server); - - server.startCallback(() => { - resolve(); - }); - }) - ), - Promise.resolve() - ); - } - - it("should return the port when the port is specified", async () => { - const retryCount = 1; - - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount; - - const freePort = await Server.getFreePort(9082); - - expect(freePort).toEqual(9082); - }); - - it("should return the port when the port is `null`", async () => { - const retryCount = 2; - - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount; - - await createDummyServers(retryCount); - - const freePort = await Server.getFreePort(null); - - expect(freePort).toEqual(60000 + retryCount); - - const { page, browser } = await runBrowser(); - - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${devServerPort}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - await browser.close(); - }); - - it("should return the port when the port is undefined", async () => { - const retryCount = 3; - - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount; - - await createDummyServers(retryCount); - - // eslint-disable-next-line no-undefined - const freePort = await Server.getFreePort(undefined); - - expect(freePort).toEqual(60000 + retryCount); - - const { page, browser } = await runBrowser(); - - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${devServerPort}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - await browser.close(); - }); - - it("should retry finding the port for up to defaultPortRetry times (number)", async () => { - const retryCount = 4; - - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount; - - await createDummyServers(retryCount); - - const freePort = await Server.getFreePort(); - - expect(freePort).toEqual(60000 + retryCount); - - const { page, browser } = await runBrowser(); - - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${devServerPort}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - await browser.close(); - }); - - it("should retry finding the port for up to defaultPortRetry times (string)", async () => { - const retryCount = 5; - - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = retryCount; - - await createDummyServers(retryCount); - - const freePort = await Server.getFreePort(); - - expect(freePort).toEqual(60000 + retryCount); - - const { page, browser } = await runBrowser(); - - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${devServerPort}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - await browser.close(); - }); - - it("should retry finding the port when serial ports are busy", async () => { - const busyPorts = [60000, 60001, 60002, 60003, 60004, 60005]; - - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = 1000; - - await createDummyServers(busyPorts); - - const freePort = await Server.getFreePort(); - - expect(freePort).toBeGreaterThan(60005); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${devServerPort}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - } - }); - - it("should throw the error when the port isn't found", async () => { - expect.assertions(1); - - jest.mock( - "webpack-dev-server/lib/getPort", - () => () => Promise.reject(new Error("busy")) - ); - - process.env.WEBPACK_DEV_SERVER_PORT_RETRY = 1; - - try { - await Server.getFreePort(); - } catch (error) { - expect(error.message).toMatchSnapshot(); - } - }); - }); - - describe("Server.checkHostHeader", () => { - it("should allow access for every requests using an IP", () => { - const options = {}; - - const tests = [ - "192.168.1.123", - "192.168.1.2:8080", - "[::1]", - "[::1]:8080", - "[ad42::1de2:54c2:c2fa:1234]", - "[ad42::1de2:54c2:c2fa:1234]:8080" - ]; - - const compiler = webpack(config); - const server = new Server(options, compiler); - - tests.forEach(test => { - const headers = { host: test }; - - if (!server.checkHeader(headers, "host")) { - throw new Error("Validation didn't pass"); - } - }); - }); - - it('should allow URLs with scheme for checking origin when the "option.client.webSocketURL" is object', async () => { - const options = { - port, - client: { - reconnect: false, - webSocketURL: { - hostname: "test.host" - } - }, - webSocketServer: "ws" - }; - const headers = { - origin: "https://test.host" - }; - - const compiler = webpack(config); - const server = new Server(options, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - if (!server.checkHeader(headers, "origin")) { - throw new Error("Validation didn't fail"); - } - - await new Promise(resolve => { - const interval = setInterval(() => { - const needFinish = consoleMessages.filter(message => - /Trying to reconnect/.test(message.text()) - ); - - if (needFinish.length > 0) { - clearInterval(interval); - resolve(); - } - }, 100); - }); - - expect(webSocketRequests[0].url).toMatchSnapshot("web socket URL"); - - expect(response.status()).toMatchSnapshot("response status"); - - // TODO: not stable on lynx linux ci - // expect( - // // net::ERR_NAME_NOT_RESOLVED can be multiple times - // consoleMessages.map(message => message.text()).slice(0, 7) - // ).toMatchSnapshot("console messages"); - - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/bonjour.test.js b/packages/rspack-dev-server/tests/e2e/bonjour.test.js deleted file mode 100644 index 7e4ea9b8093..00000000000 --- a/packages/rspack-dev-server/tests/e2e/bonjour.test.js +++ /dev/null @@ -1,341 +0,0 @@ -"use strict"; - -const os = require("os"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/simple-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").bonjour; - -describe("bonjour option", () => { - let mockPublish; - let mockUnpublishAll; - let mockDestroy; - - beforeEach(() => { - mockPublish = jest.fn(); - mockUnpublishAll = jest.fn(callback => { - callback(); - }); - mockDestroy = jest.fn(); - }); - - describe("as true", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - jest.mock("bonjour-service", () => { - return { - Bonjour: jest.fn().mockImplementation(() => { - return { - publish: mockPublish, - unpublishAll: mockUnpublishAll, - destroy: mockDestroy - }; - }) - }; - }); - - compiler = webpack(config); - - server = new Server({ port, bonjour: true }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - - mockPublish.mockReset(); - mockUnpublishAll.mockReset(); - mockDestroy.mockReset(); - }); - - it("should call bonjour with correct params", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(mockPublish).toHaveBeenCalledTimes(1); - - expect(mockPublish).toHaveBeenCalledWith({ - name: `Webpack Dev Server ${os.hostname()}:${port}`, - port, - type: "http", - subtypes: ["webpack"] - }); - - expect(mockUnpublishAll).toHaveBeenCalledTimes(0); - expect(mockDestroy).toHaveBeenCalledTimes(0); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("with 'server' option", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - jest.mock("bonjour-service", () => { - return { - Bonjour: jest.fn().mockImplementation(() => { - return { - publish: mockPublish, - unpublishAll: mockUnpublishAll, - destroy: mockDestroy - }; - }) - }; - }); - - compiler = webpack(config); - - server = new Server({ bonjour: true, port, server: "https" }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should call bonjour with 'https' type", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(mockPublish).toHaveBeenCalledTimes(1); - - expect(mockPublish).toHaveBeenCalledWith({ - name: `Webpack Dev Server ${os.hostname()}:${port}`, - port, - type: "https", - subtypes: ["webpack"] - }); - - expect(mockUnpublishAll).toHaveBeenCalledTimes(0); - expect(mockDestroy).toHaveBeenCalledTimes(0); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as object", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - jest.mock("bonjour-service", () => { - return { - Bonjour: jest.fn().mockImplementation(() => { - return { - publish: mockPublish, - unpublishAll: mockUnpublishAll, - destroy: mockDestroy - }; - }) - }; - }); - - compiler = webpack(config); - - server = new Server( - { - port, - bonjour: { - type: "https", - protocol: "udp" - } - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should apply bonjour options", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(mockPublish).toHaveBeenCalledTimes(1); - - expect(mockPublish).toHaveBeenCalledWith({ - name: `Webpack Dev Server ${os.hostname()}:${port}`, - port, - type: "https", - protocol: "udp", - subtypes: ["webpack"] - }); - - expect(mockUnpublishAll).toHaveBeenCalledTimes(0); - expect(mockDestroy).toHaveBeenCalledTimes(0); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("bonjour object and 'server' option", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - jest.mock("bonjour-service", () => { - return { - Bonjour: jest.fn().mockImplementation(() => { - return { - publish: mockPublish, - unpublishAll: mockUnpublishAll, - destroy: mockDestroy - }; - }) - }; - }); - - compiler = webpack(config); - - server = new Server( - { - port, - bonjour: { - type: "http", - protocol: "udp" - }, - server: { - type: "https" - } - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should apply bonjour options", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(mockPublish).toHaveBeenCalledTimes(1); - - expect(mockPublish).toHaveBeenCalledWith({ - name: `Webpack Dev Server ${os.hostname()}:${port}`, - port, - type: "http", - protocol: "udp", - subtypes: ["webpack"] - }); - - expect(mockUnpublishAll).toHaveBeenCalledTimes(0); - expect(mockDestroy).toHaveBeenCalledTimes(0); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/built-in-routes.test.js b/packages/rspack-dev-server/tests/e2e/built-in-routes.test.js deleted file mode 100644 index fc17959c97d..00000000000 --- a/packages/rspack-dev-server/tests/e2e/built-in-routes.test.js +++ /dev/null @@ -1,303 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const multiConfig = require("../fixtures/multi-public-path-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").routes; - -describe("Built in routes", () => { - describe("with simple config", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - server = new Server({ port }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handles GET request to sockjs bundle", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/__webpack_dev_server__/sockjs.bundle.js`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handles HEAD request to sockjs bundle", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - - interceptedRequest.continue({ method: "HEAD" }, 10); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/__webpack_dev_server__/sockjs.bundle.js`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle GET request to invalidate endpoint", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/webpack-dev-server/invalidate`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).not.toEqual("text/html"); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle GET request to directory index and list all middleware directories", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/webpack-dev-server/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("directory list"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle HEAD request to directory index", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - - interceptedRequest.continue({ method: "HEAD" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/webpack-dev-server/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("directory list"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle GET request to magic async chunk", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - }); - - it("should handle HEAD request to magic async chunk", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - - interceptedRequest.continue({ method: "HEAD" }); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - }); - }); - - describe("with multi config", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(multiConfig); - server = new Server({ port }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to directory index and list all middleware directories", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/webpack-dev-server/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("directory list"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/client-reconnect.test.js b/packages/rspack-dev-server/tests/e2e/client-reconnect.test.js deleted file mode 100644 index 8e458fe1c36..00000000000 --- a/packages/rspack-dev-server/tests/e2e/client-reconnect.test.js +++ /dev/null @@ -1,205 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/simple-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["client-reconnect-option"]; - -describe("client.reconnect option", () => { - describe("specified as true", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server({ port, client: { reconnect: true } }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - }); - - it("should try to reconnect unlimited times", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - try { - expect(response.status()).toMatchSnapshot("response status"); - } catch (error) { - throw error; - } finally { - await server.stop(); - } - - let interval; - - await new Promise(resolve => { - interval = setInterval(() => { - const retryingMessages = consoleMessages.filter(message => - message.text().includes("Trying to reconnect...") - ); - - if (retryingMessages.length >= 5) { - clearInterval(interval); - - resolve(); - } - }, 1000); - }); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("specified as false", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server({ port, client: { reconnect: false } }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - }); - - it("should not try to reconnect", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - try { - expect(response.status()).toMatchSnapshot("response status"); - } catch (error) { - throw error; - } finally { - await server.stop(); - } - - // Can't wait to check for unlimited times so wait only for couple retries - await new Promise(resolve => - setTimeout( - () => { - resolve(); - }, - // eslint-disable-next-line no-restricted-properties - 1000 * Math.pow(2, 3) - ) - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("specified as number", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server({ port, client: { reconnect: 2 } }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - }); - - it("should try to reconnect 2 times", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - try { - expect(response.status()).toMatchSnapshot("response status"); - } catch (error) { - throw error; - } finally { - await server.stop(); - } - - // Can't wait to check for unlimited times so wait only for couple retries - await new Promise(resolve => - setTimeout( - () => { - resolve(); - }, - // eslint-disable-next-line no-restricted-properties - 1000 * Math.pow(2, 3) - ) - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/client.test.js b/packages/rspack-dev-server/tests/e2e/client.test.js deleted file mode 100644 index ab9e8529ade..00000000000 --- a/packages/rspack-dev-server/tests/e2e/client.test.js +++ /dev/null @@ -1,286 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/simple-config-other/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["client-option"]; - -describe("client option", () => { - describe("default behaviour", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - client: { - webSocketTransport: "sockjs" - }, - webSocketServer: "sockjs", - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("responds with a 200 status code for /ws path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/ws`, { - waitUntil: "networkidle0" - }); - - // overlay should be true by default - expect(server.options.client.overlay).toBe(true); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("should respect path option", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - client: { - webSocketTransport: "sockjs" - }, - webSocketServer: { - type: "sockjs", - options: { - host: "localhost", - port, - path: "/foo/test/bar" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("responds with a 200 status code for /foo/test/bar path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/foo/test/bar`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("configure client entry", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - client: false, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should disable client entry", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).not.toMatch(/client\/index\.js/); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("webSocketTransport", () => { - const clientModes = [ - { - title: 'as a string ("sockjs")', - client: { - webSocketTransport: "sockjs" - }, - webSocketServer: "sockjs", - shouldThrow: false - }, - { - title: 'as a string ("ws")', - client: { - webSocketTransport: "ws" - }, - webSocketServer: "ws", - shouldThrow: false - }, - { - title: 'as a path ("sockjs")', - client: { - webSocketTransport: require.resolve( - "webpack-dev-server/client/clients/SockJSClient" - ) - }, - webSocketServer: "sockjs", - shouldThrow: false - }, - { - title: 'as a path ("ws")', - client: { - webSocketTransport: require.resolve( - "webpack-dev-server/client/clients/WebSocketClient" - ) - }, - webSocketServer: "ws", - shouldThrow: false - }, - { - title: "as a nonexistent path (sockjs)", - client: { - webSocketTransport: "/bad/path/to/implementation" - }, - webSocketServer: "sockjs", - shouldThrow: true - }, - { - title: "as a nonexistent path (ws)", - client: { - webSocketTransport: "/bad/path/to/implementation" - }, - webSocketServer: "ws", - shouldThrow: true - } - ]; - - describe("passed to server", () => { - clientModes.forEach(data => { - it(`${data.title} ${ - data.shouldThrow ? "should throw" : "should not throw" - }`, async () => { - const compiler = webpack(config); - - const server = new Server( - { - client: data.client, - port - }, - compiler - ); - - let thrownError; - - try { - await server.start(); - } catch (error) { - thrownError = error; - } - - if (data.shouldThrow) { - expect(thrownError.message).toMatch( - /client\.webSocketTransport must be a string/ - ); - } - - await server.stop(); - }); - }); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/compress.test.js b/packages/rspack-dev-server/tests/e2e/compress.test.js deleted file mode 100644 index 8cc81c354c0..00000000000 --- a/packages/rspack-dev-server/tests/e2e/compress.test.js +++ /dev/null @@ -1,180 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/simple-config-other/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["compress-option"]; - -describe("compress option", () => { - describe("enabled by default when not specified", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server({ port }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to bundle file", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(response.headers()["content-encoding"]).toMatchSnapshot( - "response headers content-encoding" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as true", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - compress: true, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to bundle file", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(response.headers()["content-encoding"]).toMatchSnapshot( - "response headers content-encoding" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as false", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - compress: false, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to bundle file", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(response.headers()["content-encoding"]).toMatchSnapshot( - "response headers content-encoding" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/entry.test.js b/packages/rspack-dev-server/tests/e2e/entry.test.js deleted file mode 100644 index cf0bca0371a..00000000000 --- a/packages/rspack-dev-server/tests/e2e/entry.test.js +++ /dev/null @@ -1,435 +0,0 @@ -"use strict"; - -const path = require("path"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").entry; - -const HOT_ENABLED_MESSAGE = - "[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled."; - -const waitForConsoleLogFinished = async consoleLogs => { - await new Promise(resolve => { - const interval = setInterval(() => { - if (consoleLogs.includes(HOT_ENABLED_MESSAGE)) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); -}; - -describe("entry", () => { - const entryFirst = path.resolve( - __dirname, - "../fixtures/client-config/foo.js" - ); - const entrySecond = path.resolve( - __dirname, - "../fixtures/client-config/bar.js" - ); - - it("should work with single entry", async () => { - const compiler = webpack({ ...config, entry: entryFirst }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should work with single array entry", async () => { - const compiler = webpack({ ...config, entry: [entryFirst, entrySecond] }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should work with object entry", async () => { - const compiler = webpack({ - ...config, - entry: { - main: { import: entryFirst } - } - }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should work with dynamic entry", async () => { - const compiler = webpack({ ...config, entry: () => entryFirst }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should work with dynamic async entry", async () => { - const compiler = webpack({ - ...config, - entry: () => new Promise(resolve => resolve([entryFirst])) - }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should work with multiple entries", async () => { - const compiler = webpack({ - ...config, - entry: { - foo: entryFirst, - bar: entrySecond - }, - optimization: { - runtimeChunk: { - name: "runtime" - } - } - }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/test.html`, { - waitUntil: "networkidle0" - }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/runtime.js` }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/foo.js` }); - await waitForConsoleLogFinished(consoleMessages); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should work with multiple entries #2", async () => { - const compiler = webpack({ - ...config, - entry: { - foo: entryFirst, - bar: entrySecond - }, - optimization: { - runtimeChunk: { - name: "runtime" - } - } - }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/test.html`, { - waitUntil: "networkidle0" - }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/runtime.js` }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/bar.js` }); - await waitForConsoleLogFinished(consoleMessages); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should work with multiple entries and "dependOn"', async () => { - const compiler = webpack({ - ...config, - entry: { - foo: { - import: entryFirst, - dependOn: "bar" - }, - bar: entrySecond - } - }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/test.html`, { - waitUntil: "networkidle0" - }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/bar.js` }); - await page.addScriptTag({ url: `http://127.0.0.1:${port}/foo.js` }); - await waitForConsoleLogFinished(consoleMessages); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should work with empty", async () => { - const compiler = webpack({ - ...config, - entry: {} - }); - - new webpack.EntryPlugin(compiler.context, entryFirst, { - name: "main" - }).apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/headers.test.js b/packages/rspack-dev-server/tests/e2e/headers.test.js deleted file mode 100644 index aaea931d29d..00000000000 --- a/packages/rspack-dev-server/tests/e2e/headers.test.js +++ /dev/null @@ -1,458 +0,0 @@ -"use strict"; - -const request = require("supertest"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/simple-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["headers-option"]; - -describe("headers option", () => { - describe("as a string", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - headers: { "X-Foo": "dev-server headers" }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request with headers", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["x-foo"]).toMatchSnapshot( - "response headers x-foo" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as an array of objects", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - headers: [ - { - key: "X-Foo", - value: "value1" - }, - { - key: "X-Bar", - value: "value2" - } - ], - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request with headers", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["x-foo"]).toMatchSnapshot( - "response headers x-foo" - ); - - expect(response.headers()["x-bar"]).toMatchSnapshot( - "response headers x-bar" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as an array", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - headers: { "X-Bar": ["key1=value1", "key2=value2"] }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request with headers as an array", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["x-bar"]).toMatchSnapshot( - "response headers x-bar" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as a function", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - headers: () => { - return { "X-Bar": ["key1=value1", "key2=value2"] }; - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request with headers as a function", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["x-bar"]).toMatchSnapshot( - "response headers x-bar" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as a function returning an array", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - headers: () => [ - { - key: "X-Foo", - value: "value1" - }, - { - key: "X-Bar", - value: "value2" - } - ], - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request with headers", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["x-foo"]).toMatchSnapshot( - "response headers x-foo" - ); - - expect(response.headers()["x-bar"]).toMatchSnapshot( - "response headers x-bar" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("dev middleware headers take precedence for dev middleware output files", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - headers: { "X-Foo": "dev-server-headers" }, - devMiddleware: { - headers: { "X-Foo": "dev-middleware-headers" } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request with headers as a function", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["x-foo"]).toMatchSnapshot( - "response headers x-foo" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as a string and support HEAD request", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - let req; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - headers: { "X-Foo": "dev-server headers" }, - port - }, - compiler - ); - - await server.start(); - - req = request(server.app); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle HEAD request with headers", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["x-foo"]).toMatchSnapshot( - "response headers x-foo" - ); - expect(response.status()).toMatchSnapshot("response status"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - - const responseForHead = await req.get(`/`); - - expect(responseForHead.headers["x-foo"]).toBe("dev-server headers"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/history-api-fallback.test.js b/packages/rspack-dev-server/tests/e2e/history-api-fallback.test.js deleted file mode 100644 index 6cf5e7b6e07..00000000000 --- a/packages/rspack-dev-server/tests/e2e/history-api-fallback.test.js +++ /dev/null @@ -1,687 +0,0 @@ -"use strict"; - -const path = require("path"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/historyapifallback-config/webpack.config"); -const config2 = require("../fixtures/historyapifallback-2-config/webpack.config"); -const config3 = require("../fixtures/historyapifallback-3-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["history-api-fallback-option"]; - -describe("historyApiFallback option", () => { - describe("as boolean", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - historyApiFallback: true, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to directory", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as object", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - historyApiFallback: { - index: "/bar.html" - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to directory", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as object with static", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config2); - - server = new Server( - { - static: path.resolve( - __dirname, - "../fixtures/historyapifallback-2-config" - ), - historyApiFallback: { - index: "/bar.html" - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to directory", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should prefer static file over historyApiFallback", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/random-file.txt`, - { - waitUntil: "networkidle2" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as object with static set to false", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config3); - - server = new Server( - { - static: false, - historyApiFallback: { - index: "/bar.html" - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("historyApiFallback should work and ignore static content", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/index.html`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as object with static and rewrites", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config2); - - server = new Server( - { - port, - static: path.resolve( - __dirname, - "../fixtures/historyapifallback-2-config" - ), - historyApiFallback: { - rewrites: [ - { - from: /other/, - to: "/other.html" - }, - { - from: /.*/, - to: "/bar.html" - } - ] - } - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("historyApiFallback respect rewrites for index", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("historyApiFallback respect rewrites and shows index for unknown urls", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/acme`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("historyApiFallback respect any other specified rewrites", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/other`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe('as object with the "verbose" option', () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - let consoleSpy; - - beforeEach(async () => { - consoleSpy = jest.spyOn(global.console, "log"); - - compiler = webpack(config); - - server = new Server( - { - historyApiFallback: { - index: "/bar.html", - verbose: true - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - consoleSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); - - it("request to directory and log", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleSpy).toHaveBeenCalledWith( - "Rewriting", - "GET", - "/foo", - "to", - "/bar.html" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe('as object with the "logger" option', () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - let consoleSpy; - - beforeEach(async () => { - consoleSpy = jest.spyOn(global.console, "log"); - - compiler = webpack(config); - - server = new Server( - { - historyApiFallback: { - index: "/bar.html", - logger: consoleSpy - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - consoleSpy.mockRestore(); - await browser.close(); - await server.stop(); - }); - - it("request to directory and log", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleSpy).toHaveBeenCalledWith( - "Rewriting", - "GET", - "/foo", - "to", - "/bar.html" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("in-memory files", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config3); - - server = new Server( - { - static: path.resolve( - __dirname, - "../fixtures/historyapifallback-3-config" - ), - historyApiFallback: true, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should take precedence over static files", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo`, { - waitUntil: "networkidle0" - }); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should perform HEAD request in same way as GET", async () => { - await page.goto(`http://127.0.0.1:${port}/foo`, { - waitUntil: "networkidle0" - }); - - const responseGet = await page.evaluate(async () => { - const response = await fetch("/foo", { method: "GET" }); - - return { - contentType: response.headers.get("content-type"), - statusText: response.statusText, - text: await response.text() - }; - }); - - expect(responseGet.contentType).toMatchSnapshot( - "response headers content-type" - ); - - expect(responseGet.statusText).toMatchSnapshot("response status"); - - expect(responseGet.text).toMatchSnapshot("response text"); - - const responseHead = await page.evaluate(async () => { - const response = await fetch("/foo", { method: "HEAD" }); - - return { - contentType: response.headers.get("content-type"), - statusText: response.statusText, - text: await response.text() - }; - }); - - expect(responseHead).toMatchObject({ - ...responseGet, - // HEAD response has an empty body - text: "" - }); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/host.test.js b/packages/rspack-dev-server/tests/e2e/host.test.js deleted file mode 100644 index 9adb12273fd..00000000000 --- a/packages/rspack-dev-server/tests/e2e/host.test.js +++ /dev/null @@ -1,284 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").host; - -const ipv4 = Server.internalIPSync("v4"); -const ipv6 = Server.internalIPSync("v6"); -// macos requires root for using ip v6 -const isMacOS = process.platform === "darwin"; - -function getAddress(host, hostname) { - let address; - - if ( - typeof host === "undefined" || - (typeof host === "string" && host === "") - ) { - address = "::"; - } else if (typeof host === "string" && host === "0.0.0.0") { - address = "0.0.0.0"; - } else if (typeof host === "string" && host === "localhost") { - address = parseFloat(process.versions.node) >= 18 ? "::1" : "127.0.0.1"; - } else { - address = hostname; - } - - return { address }; -} - -describe("host", () => { - const hosts = [ - "", - // eslint-disable-next-line no-undefined - undefined, - "0.0.0.0", - "::", - "localhost", - "::1", - "127.0.0.1", - "local-ip", - "local-ipv4", - "local-ipv6" - ]; - - for (let host of hosts) { - it(`should work using "${host}" host and port as number`, async () => { - const compiler = webpack(config); - - if (!ipv6 || isMacOS) { - if (host === "::") { - host = "127.0.0.1"; - } else if (host === "::1") { - host = "127.0.0.1"; - } else if (host === "local-ipv6") { - host = "127.0.0.1"; - } - } - - const devServerOptions = { port }; - - if (host !== "") { - devServerOptions.host = host; - } - - const server = new Server(devServerOptions, compiler); - - let hostname = host; - - if (hostname === "0.0.0.0") { - hostname = "127.0.0.1"; - } else if ( - hostname === "" || - typeof hostname === "undefined" || - hostname === "::" || - hostname === "::1" - ) { - hostname = "[::1]"; - } else if (hostname === "local-ip" || hostname === "local-ipv4") { - hostname = ipv4; - } else if (hostname === "local-ipv6") { - hostname = `[${ipv6}]`; - } - - await server.start(); - - expect(server.server.address()).toMatchObject(getAddress(host, hostname)); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${hostname}:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work using "${host}" host and port as string`, async () => { - const compiler = webpack(config); - - if (!ipv6 || isMacOS) { - if (host === "::") { - host = "127.0.0.1"; - } else if (host === "::1") { - host = "127.0.0.1"; - } else if (host === "local-ipv6") { - host = "127.0.0.1"; - } - } - - const devServerOptions = { port: `${port}` }; - - if (host !== "") { - devServerOptions.host = host; - } - - const server = new Server(devServerOptions, compiler); - - let hostname = host; - - if (hostname === "0.0.0.0") { - hostname = "127.0.0.1"; - } else if ( - hostname === "" || - typeof hostname === "undefined" || - hostname === "::" || - hostname === "::1" - ) { - hostname = "[::1]"; - } else if (hostname === "local-ip" || hostname === "local-ipv4") { - hostname = ipv4; - } else if (hostname === "local-ipv6") { - hostname = `[${ipv6}]`; - } - - await server.start(); - - expect(server.server.address()).toMatchObject(getAddress(host, hostname)); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${hostname}:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work using "${host}" host and "auto" port`, async () => { - const compiler = webpack(config); - - process.env.WEBPACK_DEV_SERVER_BASE_PORT = port; - - if (!ipv6 || isMacOS) { - if (host === "::") { - host = "127.0.0.1"; - } else if (host === "::1") { - host = "127.0.0.1"; - } else if (host === "local-ipv6") { - host = "127.0.0.1"; - } - } - - const devServerOptions = { port: "auto" }; - - if (host !== "") { - devServerOptions.host = host; - } - - const server = new Server(devServerOptions, compiler); - - let hostname = host; - - if (hostname === "0.0.0.0") { - hostname = "127.0.0.1"; - } else if ( - hostname === "" || - typeof hostname === "undefined" || - hostname === "::" || - hostname === "::1" - ) { - hostname = "[::1]"; - } else if (hostname === "local-ip" || hostname === "local-ipv4") { - hostname = ipv4; - } else if (hostname === "local-ipv6") { - hostname = `[${ipv6}]`; - } - - await server.start(); - - expect(server.server.address()).toMatchObject(getAddress(host, hostname)); - - const address = server.server.address(); - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://${hostname}:${address.port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - - await browser.close(); - await server.stop(); - } - }); - } - - // TODO need test on error - // it(`should throw an error on invalid host`, async () => { - // const compiler = webpack(config); - // const server = new Server({ port, host: "unknown.unknown" }, compiler); - // const runDevServer = async () => { - // await server.start(); - // }; - // - // return expect(runDevServer()).toBeDefined(); - // }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/hot-and-live-reload.test.js b/packages/rspack-dev-server/tests/e2e/hot-and-live-reload.test.js deleted file mode 100644 index 8d4192b829f..00000000000 --- a/packages/rspack-dev-server/tests/e2e/hot-and-live-reload.test.js +++ /dev/null @@ -1,898 +0,0 @@ -/** - * @jest-environment node - */ - -"use strict"; - -const path = require("path"); -const WebSocket = require("ws"); -const SockJS = require("sockjs-client"); -const webpack = require("@rspack/core"); -const fs = require("graceful-fs"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const HTMLGeneratorPlugin = require("../helpers/html-generator-plugin"); -const reloadConfig = require("../fixtures/reload-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["hot-and-live-reload"]; -const config = require("../fixtures/client-config/webpack.config"); -const multiCompilerConfig = require("../fixtures/multi-compiler-one-configuration/webpack.config"); - -const cssFilePath = path.resolve( - __dirname, - "../fixtures/reload-config/main.css" -); - -const INVALID_MESSAGE = "[webpack-dev-server] App updated. Recompiling..."; - -describe("hot and live reload", () => { - // "sockjs" client cannot add additional headers - const modes = [ - { - title: "should work and refresh content using hot module replacement" - }, - { - title: "should work and do nothing when web socket server disabled", - options: { - webSocketServer: false - } - }, - // Default web socket serve ("ws") - { - title: - "should work and refresh content using hot module replacement when hot enabled", - options: { - hot: true - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload enabled", - options: { - liveReload: true - } - }, - { - title: "should not refresh content when hot and no live reload disabled", - options: { - hot: false, - liveReload: false - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload disabled and hot enabled", - options: { - liveReload: false, - hot: true - } - }, - { - title: "should work and refresh content using live reload", - options: { - liveReload: true, - hot: false - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload enabled and hot disabled", - options: { - liveReload: true, - hot: true - } - }, - // "ws" web socket serve - { - title: - "should work and refresh content using hot module replacement when hot enabled", - options: { - webSocketServer: "ws", - hot: true - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload enabled", - options: { - webSocketServer: "ws", - liveReload: true - } - }, - { - title: "should not refresh content when hot and no live reload disabled", - options: { - webSocketServer: "ws", - hot: false, - liveReload: false - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload disabled and hot enabled", - options: { - webSocketServer: "ws", - liveReload: false, - hot: true - } - }, - { - title: - "should work and refresh content using live reload when live reload enabled and hot disabled", - options: { - webSocketServer: "ws", - liveReload: true, - hot: false - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload and hot enabled", - options: { - webSocketServer: "ws", - liveReload: true, - hot: true - } - }, - // "sockjs" web socket serve - { - title: - "should work and refresh content using hot module replacement when hot enabled", - options: { - allowedHosts: "all", - - webSocketServer: "sockjs", - hot: true - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload enabled", - options: { - allowedHosts: "all", - - webSocketServer: "sockjs", - liveReload: true - } - }, - { - title: "should not refresh content when hot and no live reload disabled", - options: { - allowedHosts: "all", - - webSocketServer: "sockjs", - hot: false, - liveReload: false - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload disabled and hot enabled", - options: { - allowedHosts: "all", - - webSocketServer: "sockjs", - liveReload: false, - hot: true - } - }, - { - title: - "should work and refresh content using live reload when live reload disabled and hot enabled", - options: { - allowedHosts: "all", - - webSocketServer: "sockjs", - liveReload: true, - hot: false - } - }, - { - title: - "should work and refresh content using hot module replacement when live reload and hot enabled", - options: { - allowedHosts: "all", - - webSocketServer: "sockjs", - liveReload: true, - hot: true - } - }, - { - title: - 'should work and allow to disable hot module replacement using the "webpack-dev-server-hot=false"', - query: "?webpack-dev-server-hot=false", - options: { - liveReload: true, - hot: true - } - }, - { - title: - 'should work and allow to disable live reload using the "webpack-dev-server-live-reload=false"', - query: "?webpack-dev-server-live-reload=false", - options: { - liveReload: true, - hot: false - } - }, - { - title: - 'should work and allow to disable hot module replacement and live reload using the "webpack-dev-server-hot=false&webpack-dev-server-live-reload=false"', - query: - "?webpack-dev-server-hot=false&webpack-dev-server-live-reload=false", - options: { - liveReload: true, - hot: true - } - }, - { - title: "should work with manual client setup", - webpackOptions: { - entry: [ - require.resolve("@rspack/dev-server/client/index.js"), - require.resolve("../fixtures/reload-config/foo.js") - ] - }, - options: { - client: false, - liveReload: true, - hot: true - } - }, - // TODO we still output logs from webpack, need to improve this - { - title: - "should work with manual client setup and allow to enable hot module replacement", - webpackOptions: { - entry: [ - "@rspack/core/hot/dev-server", - `${require.resolve("@rspack/dev-server/client/index.js")}?hot=true`, - require.resolve("../fixtures/reload-config/foo.js") - ], - plugins: [ - new webpack.HotModuleReplacementPlugin(), - new HTMLGeneratorPlugin() - ] - }, - options: { - client: false, - liveReload: false, - hot: false - } - }, - { - title: - "should work with manual client setup and allow to disable hot module replacement", - webpackOptions: { - entry: [ - `${require.resolve("@rspack/dev-server/client/index.js")}?hot=false`, - require.resolve("../fixtures/reload-config/foo.js") - ] - }, - options: { - client: false, - liveReload: true, - hot: true - } - }, - { - title: - "should work with manual client setup and allow to enable live reload", - webpackOptions: { - entry: [ - `${require.resolve("@rspack/dev-server/client/index.js")}?live-reload=true`, - require.resolve("../fixtures/reload-config/foo.js") - ] - }, - options: { - client: false, - liveReload: false, - hot: false - } - }, - { - title: - "should work with manual client setup and allow to disable live reload", - webpackOptions: { - entry: [ - `${require.resolve("@rspack/dev-server/client/index.js")}?live-reload=false`, - require.resolve("../fixtures/reload-config/foo.js") - ] - }, - options: { - client: false, - liveReload: true, - hot: false - } - } - ]; - - let browser; - let server; - - beforeEach(() => { - fs.writeFileSync(cssFilePath, "body { background-color: rgb(0, 0, 255); }"); - }); - - afterEach(async () => { - if (browser) { - await browser.close(); - } - - if (server) { - await server.stop(); - } - - fs.unlinkSync(cssFilePath); - }); - - modes.forEach(mode => { - const webSocketServerTitle = - mode.options && mode.options.webSocketServer - ? mode.options.webSocketServer - : "default"; - - it(`${mode.title} (${webSocketServerTitle})`, async () => { - const webpackOptions = { ...reloadConfig, ...mode.webpackOptions }; - const compiler = webpack(webpackOptions); - const testDevServerOptions = mode.options || {}; - const devServerOptions = { port, ...testDevServerOptions }; - - server = new Server(devServerOptions, compiler); - - await server.start(); - - const webSocketServerLaunched = - testDevServerOptions.webSocketServer !== false; - - await new Promise(resolve => { - const webSocketTransport = - typeof testDevServerOptions.webSocketServer !== "undefined" && - testDevServerOptions.webSocketServer !== false - ? testDevServerOptions.webSocketServer - : "ws"; - - if (webSocketTransport === "ws") { - const ws = new WebSocket( - `ws://127.0.0.1:${devServerOptions.port}/ws`, - { - headers: { - host: `127.0.0.1:${devServerOptions.port}`, - origin: `http://127.0.0.1:${devServerOptions.port}` - } - } - ); - - let opened = false; - let received = false; - let errored = false; - - ws.on("error", error => { - if (!webSocketServerLaunched && /404/.test(error)) { - errored = true; - } else { - errored = true; - } - - ws.close(); - }); - - ws.on("open", () => { - opened = true; - }); - - ws.on("message", data => { - const message = JSON.parse(data.toString()); - - if (message.type === "ok") { - received = true; - - ws.close(); - } - }); - - ws.on("close", () => { - if (opened && received && !errored) { - resolve(); - } else if (!webSocketServerLaunched && errored) { - resolve(); - } - }); - } else { - const sockjs = new SockJS( - `http://127.0.0.1:${devServerOptions.port}/ws` - ); - - let opened = false; - let received = false; - let errored = false; - - sockjs.onerror = () => { - errored = true; - }; - - sockjs.onopen = () => { - opened = true; - }; - - sockjs.onmessage = ({ data }) => { - const message = JSON.parse(data.toString()); - - if (message.type === "ok") { - received = true; - - sockjs.close(); - } - }; - - sockjs.onclose = event => { - if (opened && received && !errored) { - resolve(); - } else if (event && event.reason === "Cannot connect to server") { - resolve(); - } - }; - } - }); - - const launched = await runBrowser(); - - ({ browser } = launched); - - const page = launched.page; - - const consoleMessages = []; - const pageErrors = []; - - let doneHotUpdate = false; - let hasDisconnectedMessage = false; - - page - .on("console", message => { - if (!hasDisconnectedMessage) { - const text = message.text(); - - hasDisconnectedMessage = /Disconnected!/.test(text); - consoleMessages.push(text); - } - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", requestObj => { - if (/\.hot-update\.json$/.test(requestObj.url())) { - doneHotUpdate = true; - } - }); - - await page.goto(`http://localhost:${port}/${mode.query || ""}`, { - waitUntil: "networkidle0" - }); - - const backgroundColorBefore = await page.evaluate(() => { - const body = document.body; - - return getComputedStyle(body)["background-color"]; - }); - - expect(backgroundColorBefore).toEqual("rgb(0, 0, 255)"); - - fs.writeFileSync( - cssFilePath, - "body { background-color: rgb(255, 0, 0); }" - ); - - let waitHot = - typeof testDevServerOptions.hot !== "undefined" - ? testDevServerOptions.hot - : true; - let waitLiveReload = - typeof testDevServerOptions.liveReload !== "undefined" - ? testDevServerOptions.liveReload - : true; - - if (webSocketServerLaunched === false) { - waitHot = false; - waitLiveReload = false; - } - - if (Array.isArray(webpackOptions.entry)) { - if (webpackOptions.entry.some(item => item.includes("hot=true"))) { - waitHot = true; - } else if ( - webpackOptions.entry.some(item => item.includes("hot=false")) - ) { - waitHot = false; - } - } - - if (Array.isArray(webpackOptions.entry)) { - if ( - webpackOptions.entry.some(item => item.includes("live-reload=true")) - ) { - waitLiveReload = true; - } else if ( - webpackOptions.entry.some(item => item.includes("live-reload=false")) - ) { - waitLiveReload = false; - } - } - - const query = mode.query || ""; - - if (query.includes("webpack-dev-server-hot=false")) { - waitHot = false; - } - - if (query.includes("webpack-dev-server-live-reload=false")) { - waitLiveReload = false; - } - - if (waitHot) { - await page.waitForFunction( - () => - getComputedStyle(document.body)["background-color"] === - "rgb(255, 0, 0)" - ); - - expect(doneHotUpdate).toBe(true); - } else if (waitLiveReload) { - await page.waitForNavigation({ - waitUntil: "networkidle0" - }); - } else if (webSocketServerLaunched) { - await new Promise(resolve => { - const interval = setInterval(() => { - if (consoleMessages.includes(INVALID_MESSAGE)) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); - } - - const backgroundColorAfter = await page.evaluate(() => { - const body = document.body; - - return getComputedStyle(body)["background-color"]; - }); - - if (!waitHot && !waitLiveReload) { - expect(backgroundColorAfter).toEqual("rgb(0, 0, 255)"); - } else { - expect(backgroundColorAfter).toEqual("rgb(255, 0, 0)"); - } - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); - -// the following cases check to make sure that the HMR -// plugin is actually added - -// describe("simple hot config HMR plugin", () => { -// let compiler; -// let server; -// let page; -// let browser; -// let pageErrors; -// let consoleMessages; - -// beforeEach(async () => { -// compiler = webpack(config); - -// ({ page, browser } = await runBrowser()); - -// pageErrors = []; -// consoleMessages = []; -// }); - -// afterEach(async () => { -// await browser.close(); -// await server.stop(); -// }); - -// it("should register the HMR plugin before compilation is complete", async () => { -// let pluginFound = false; - -// compiler.hooks.compilation.intercept({ -// register: (tapInfo) => { -// if (tapInfo.name === "HotModuleReplacementPlugin") { -// pluginFound = true; -// } - -// return tapInfo; -// }, -// }); - -// server = new Server({ port }, compiler); - -// await server.start(); - -// expect(pluginFound).toBe(true); - -// page -// .on("console", (message) => { -// consoleMessages.push(message); -// }) -// .on("pageerror", (error) => { -// pageErrors.push(error); -// }); - -// const response = await page.goto(`http://127.0.0.1:${port}/`, { -// waitUntil: "networkidle0", -// }); - -// expect(response.status()).toMatchSnapshot("response status"); - -// expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( -// "console messages", -// ); - -// expect(pageErrors).toMatchSnapshot("page errors"); -// }); -// }); - -// describe("simple hot config HMR plugin with already added HMR plugin", () => { -// let compiler; -// let server; -// let page; -// let browser; -// let pageErrors; -// let consoleMessages; - -// beforeEach(async () => { -// compiler = webpack({ -// ...config, -// plugins: [...config.plugins, new webpack.HotModuleReplacementPlugin()], -// }); - -// ({ page, browser } = await runBrowser()); - -// pageErrors = []; -// consoleMessages = []; -// }); - -// afterEach(async () => { -// await browser.close(); -// await server.stop(); -// }); - -// it("should register the HMR plugin before compilation is complete", async () => { -// let pluginFound = false; - -// compiler.hooks.compilation.intercept({ -// register: (tapInfo) => { -// if (tapInfo.name === "HotModuleReplacementPlugin") { -// pluginFound = true; -// } - -// return tapInfo; -// }, -// }); - -// server = new Server({ port }, compiler); - -// await server.start(); - -// expect(compiler.options.plugins).toHaveLength(2); -// expect(pluginFound).toBe(true); - -// page -// .on("console", (message) => { -// consoleMessages.push(message); -// }) -// .on("pageerror", (error) => { -// pageErrors.push(error); -// }); - -// const response = await page.goto(`http://127.0.0.1:${port}/`, { -// waitUntil: "networkidle0", -// }); - -// expect(response.status()).toMatchSnapshot("response status"); - -// expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( -// "console messages", -// ); - -// expect(pageErrors).toMatchSnapshot("page errors"); -// }); -// }); - -// describe("simple config with already added HMR plugin", () => { -// let loggerWarnSpy; -// let getInfrastructureLoggerSpy; -// let compiler; -// let server; - -// beforeEach(() => { -// compiler = webpack({ -// ...config, -// devServer: { hot: false }, -// plugins: [...config.plugins, new webpack.HotModuleReplacementPlugin()], -// }); - -// loggerWarnSpy = jest.fn(); - -// getInfrastructureLoggerSpy = jest -// .spyOn(compiler, "getInfrastructureLogger") -// .mockImplementation(() => { -// return { -// warn: loggerWarnSpy, -// info: () => { }, -// log: () => { }, -// }; -// }); -// }); - -// afterEach(() => { -// getInfrastructureLoggerSpy.mockRestore(); -// loggerWarnSpy.mockRestore(); -// }); - -// it("should show warning with hot normalized as true", async () => { -// server = new Server({ port }, compiler); - -// await server.start(); - -// expect(loggerWarnSpy).toHaveBeenCalledWith( -// `"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`, -// ); - -// await server.stop(); -// }); - -// it(`should show warning with "hot: true"`, async () => { -// server = new Server({ port, hot: true }, compiler); - -// await server.start(); - -// expect(loggerWarnSpy).toHaveBeenCalledWith( -// `"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`, -// ); - -// await server.stop(); -// }); - -// it(`should not show warning with "hot: false"`, async () => { -// server = new Server({ port, hot: false }, compiler); - -// await server.start(); - -// expect(loggerWarnSpy).not.toHaveBeenCalledWith( -// `"hot: true" automatically applies HMR plugin, you don't have to add it manually to your webpack configuration.`, -// ); - -// await server.stop(); -// }); -// }); - -// describe("multi compiler hot config HMR plugin", () => { -// let compiler; -// let server; -// let page; -// let browser; -// let pageErrors; -// let consoleMessages; - -// beforeEach(async () => { -// compiler = webpack(multiCompilerConfig); - -// ({ page, browser } = await runBrowser()); - -// pageErrors = []; -// consoleMessages = []; -// }); - -// afterEach(async () => { -// await browser.close(); -// await server.stop(); -// }); - -// it("should register the HMR plugin before compilation is complete", async () => { -// let pluginFound = false; - -// compiler.compilers[0].hooks.compilation.intercept({ -// register: (tapInfo) => { -// if (tapInfo.name === "HotModuleReplacementPlugin") { -// pluginFound = true; -// } - -// return tapInfo; -// }, -// }); - -// server = new Server({ port }, compiler); - -// await server.start(); - -// expect(pluginFound).toBe(true); - -// page -// .on("console", (message) => { -// consoleMessages.push(message); -// }) -// .on("pageerror", (error) => { -// pageErrors.push(error); -// }); - -// const response = await page.goto(`http://127.0.0.1:${port}/`, { -// waitUntil: "networkidle0", -// }); - -// expect(response.status()).toMatchSnapshot("response status"); - -// expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( -// "console messages", -// ); - -// expect(pageErrors).toMatchSnapshot("page errors"); -// }); -// }); - -// describe("hot disabled HMR plugin", () => { -// let compiler; -// let server; -// let page; -// let browser; -// let pageErrors; -// let consoleMessages; - -// beforeEach(async () => { -// compiler = webpack(config); - -// ({ page, browser } = await runBrowser()); - -// pageErrors = []; -// consoleMessages = []; -// }); - -// afterEach(async () => { -// await browser.close(); -// await server.stop(); -// }); - -// it("should NOT register the HMR plugin before compilation is complete", async () => { -// let pluginFound = false; - -// compiler.hooks.compilation.intercept({ -// register: (tapInfo) => { -// if (tapInfo.name === "HotModuleReplacementPlugin") { -// pluginFound = true; -// } - -// return tapInfo; -// }, -// }); - -// server = new Server({ port, hot: false }, compiler); - -// await server.start(); - -// expect(pluginFound).toBe(false); - -// page -// .on("console", (message) => { -// consoleMessages.push(message); -// }) -// .on("pageerror", (error) => { -// pageErrors.push(error); -// }); - -// const response = await page.goto(`http://127.0.0.1:${port}/`, { -// waitUntil: "networkidle0", -// }); - -// expect(response.status()).toMatchSnapshot("response status"); - -// expect(consoleMessages.map((message) => message.text())).toMatchSnapshot( -// "console messages", -// ); - -// expect(pageErrors).toMatchSnapshot("page errors"); -// }); -// }); diff --git a/packages/rspack-dev-server/tests/e2e/ipc.test.js b/packages/rspack-dev-server/tests/e2e/ipc.test.js deleted file mode 100644 index 0098b5efee8..00000000000 --- a/packages/rspack-dev-server/tests/e2e/ipc.test.js +++ /dev/null @@ -1,354 +0,0 @@ -"use strict"; - -const os = require("os"); -const net = require("net"); -const path = require("path"); -const http = require("http"); -const webpack = require("@rspack/core"); -const httpProxy = require("http-proxy"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const sessionSubscribe = require("../helpers/session-subscribe"); -const port1 = require("../helpers/ports-map").ipc; - -const webSocketServers = ["ws", "sockjs"]; - -describe("web socket server URL", () => { - for (const webSocketServer of webSocketServers) { - const websocketURLProtocol = webSocketServer === "ws" ? "ws" : "http"; - - it(`should work with the "ipc" option using "true" value ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const proxyHost = devServerHost; - const proxyPort = port1; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - ipc: true - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const proxy = httpProxy.createProxyServer({ - target: { socketPath: server.options.ipc } - }); - - const proxyServer = http.createServer((request, response) => { - // You can define here your custom logic to handle the request - // and then proxy the request. - proxy.web(request, response); - }); - - proxyServer.on("upgrade", (request, socket, head) => { - proxy.ws(request, socket, head); - }); - - return proxyServer.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${devServerHost}:${proxyPort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "ipc" option using "string" value ("${webSocketServer}")`, async () => { - const isWindows = process.platform === "win32"; - const pipePrefix = isWindows ? "\\\\.\\pipe\\" : os.tmpdir(); - const pipeName = `webpack-dev-server.${process.pid}-1.sock`; - const ipc = path.join(pipePrefix, pipeName); - - const devServerHost = "127.0.0.1"; - const proxyHost = devServerHost; - const proxyPort = port1; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - ipc - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const proxy = httpProxy.createProxyServer({ - target: { socketPath: ipc } - }); - - const proxyServer = http.createServer((request, response) => { - // You can define here your custom logic to handle the request - // and then proxy the request. - proxy.web(request, response); - }); - - proxyServer.on("upgrade", (request, socket, head) => { - proxy.ws(request, socket, head); - }); - - return proxyServer.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${devServerHost}:${proxyPort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - // TODO un skip after implement new API - it.skip(`should work with the "ipc" option using "string" value and remove old ("${webSocketServer}")`, async () => { - const isWindows = process.platform === "win32"; - const localRelative = path.relative(process.cwd(), `${os.tmpdir()}/`); - const pipePrefix = isWindows ? "\\\\.\\pipe\\" : localRelative; - const pipeName = `webpack-dev-server.${process.pid}-2.sock`; - const ipc = path.join(pipePrefix, pipeName); - - const ipcServer = await new Promise((resolve, reject) => { - const server = net.Server(); - - server.on("error", error => { - reject(error); - }); - - return server.listen(ipc, () => { - resolve(); - }); - }); - - const devServerHost = "127.0.0.1"; - const proxyHost = devServerHost; - const proxyPort = port1; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - host: devServerHost, - ipc - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const proxy = httpProxy.createProxyServer({ - target: { socketPath: ipc } - }); - - const proxyServer = http.createServer((request, response) => { - // You can define here your custom logic to handle the request - // and then proxy the request. - proxy.web(request, response); - }); - - proxyServer.on("upgrade", (request, socket, head) => { - proxy.ws(request, socket, head); - }); - - return proxyServer.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${devServerHost}:${proxyPort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await new Promise((resolve, reject) => { - ipcServer.close(error => { - if (error) { - reject(error); - - return; - } - - resolve(); - }); - }); - await browser.close(); - await server.stop(); - } - }); - } -}); diff --git a/packages/rspack-dev-server/tests/e2e/lazy-compilation.test.js b/packages/rspack-dev-server/tests/e2e/lazy-compilation.test.js deleted file mode 100644 index cb51ef0e59f..00000000000 --- a/packages/rspack-dev-server/tests/e2e/lazy-compilation.test.js +++ /dev/null @@ -1,112 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const lazyCompilationSingleEntryConfig = require("../fixtures/lazy-compilation-single-entry/webpack.config"); -const lazyCompilationMultipleEntriesConfig = require("../fixtures/lazy-compilation-multiple-entries/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["lazy-compilation"]; - -describe("lazy compilation", () => { - // TODO jest freeze due webpack do not close `eventsource`, we should uncomment this after fix it on webpack side - it.skip(`should work with single entry`, async () => { - const compiler = webpack(lazyCompilationSingleEntryConfig); - const server = new Server({ port }, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/test.html`, { - waitUntil: "domcontentloaded" - }); - await new Promise(resolve => { - const interval = setInterval(() => { - if (consoleMessages.includes("Hey.")) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it.skip(`should work with multiple entries`, async () => { - const compiler = webpack(lazyCompilationMultipleEntriesConfig); - const server = new Server({ port }, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/test-one.html`, { - waitUntil: "domcontentloaded" - }); - await new Promise(resolve => { - const interval = setInterval(() => { - console.log(consoleMessages); - if (consoleMessages.includes("One.")) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); - - await page.goto(`http://127.0.0.1:${port}/test-two.html`, { - waitUntil: "domcontentloaded" - }); - await new Promise(resolve => { - const interval = setInterval(() => { - console.log(consoleMessages); - if (consoleMessages.includes("Two.")) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/logging.test.js b/packages/rspack-dev-server/tests/e2e/logging.test.js deleted file mode 100644 index cefbc0f98fa..00000000000 --- a/packages/rspack-dev-server/tests/e2e/logging.test.js +++ /dev/null @@ -1,242 +0,0 @@ -"use strict"; - -const path = require("path"); -const fs = require("graceful-fs"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const HTMLGeneratorPlugin = require("../helpers/html-generator-plugin"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").logging; -require("../helpers/normalize"); - -describe("logging", () => { - const webSocketServers = [ - { webSocketServer: "ws" }, - { webSocketServer: "sockjs" } - ]; - - const cases = [ - { - title: "should work and log message about live reloading is enabled", - devServerOptions: { - hot: false - } - }, - { - title: - "should work and log messages about hot and live reloading is enabled", - devServerOptions: { - hot: true - } - }, - { - title: "should work and log messages about hot is enabled", - devServerOptions: { - liveReload: false - } - }, - { - title: - "should work and log messages about hot and live reloading is enabled", - devServerOptions: { - liveReload: true - } - }, - { - title: - "should work and do not log messages about hot and live reloading is enabled", - devServerOptions: { - liveReload: false, - hot: false - } - }, - { - title: - "should work and log messages about hot and live reloading is enabled", - devServerOptions: { - liveReload: true, - hot: true - } - }, - { - title: "should work and log warnings by default", - webpackOptions: { - plugins: [ - { - apply(compiler) { - compiler.hooks.thisCompilation.tap( - "warnings-webpack-plugin", - compilation => { - compilation.warnings.push( - new Error("Warning from compilation") - ); - } - ); - } - }, - new HTMLGeneratorPlugin() - ] - } - }, - { - title: "should work and log errors by default", - webpackOptions: { - plugins: [ - { - apply(compiler) { - compiler.hooks.thisCompilation.tap( - "warnings-webpack-plugin", - compilation => { - compilation.errors.push(new Error("Error from compilation")); - } - ); - } - }, - new HTMLGeneratorPlugin() - ] - } - }, - { - title: 'should work when the "client.logging" is "info"', - devServerOptions: { - client: { - logging: "info" - } - } - }, - { - title: 'should work when the "client.logging" is "log"', - devServerOptions: { - client: { - logging: "log" - } - } - }, - { - title: 'should work when the "client.logging" is "verbose"', - devServerOptions: { - client: { - logging: "verbose" - } - } - }, - { - title: 'should work when the "client.logging" is "none"', - devServerOptions: { - client: { - logging: "none" - } - } - }, - { - title: "should work and log only error", - webpackOptions: { - plugins: [ - { - apply(compiler) { - compiler.hooks.thisCompilation.tap( - "warnings-webpack-plugin", - compilation => { - compilation.warnings.push( - new Error("Warning from compilation") - ); - compilation.errors.push(new Error("Error from compilation")); - } - ); - } - }, - new HTMLGeneratorPlugin() - ] - }, - devServerOptions: { - client: { - logging: "error" - } - } - }, - { - title: "should work and log warning and errors", - webpackOptions: { - plugins: [ - { - apply(compiler) { - compiler.hooks.thisCompilation.tap( - "warnings-webpack-plugin", - compilation => { - compilation.warnings.push( - new Error("Warning from compilation") - ); - compilation.errors.push(new Error("Error from compilation")); - } - ); - } - }, - new HTMLGeneratorPlugin() - ] - }, - devServerOptions: { - client: { - logging: "warn" - } - } - }, - { - title: "should work and log static changes", - devServerOptions: { - static: path.resolve(__dirname, "../fixtures/client-config/static") - } - } - ]; - - webSocketServers.forEach(webSocketServer => { - cases.forEach(testCase => { - it(`${testCase.title} (${ - webSocketServer.webSocketServer || "default" - })`, async () => { - const compiler = webpack({ ...config, ...testCase.webpackOptions }); - const devServerOptions = { - port, - ...testCase.devServerOptions - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - if (testCase.devServerOptions && testCase.devServerOptions.static) { - fs.writeFileSync( - path.join(testCase.devServerOptions.static, "./foo.txt"), - "Text" - ); - - await page.waitForNavigation({ - waitUntil: "networkidle0" - }); - } - - expect( - consoleMessages.map(message => message.text().replace(/\\/g, "/")) - ).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/mime-types.test.js b/packages/rspack-dev-server/tests/e2e/mime-types.test.js deleted file mode 100644 index 80005919c26..00000000000 --- a/packages/rspack-dev-server/tests/e2e/mime-types.test.js +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/mime-types-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["mime-types-option"]; - -describe("mimeTypes option", () => { - describe("as an object with a remapped type", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - devMiddleware: { - mimeTypes: { - js: "text/plain" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should request file with different js mime type", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("as an object with a custom type", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - devMiddleware: { - mimeTypes: { - custom: "text/html" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should request file with different js mime type", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/file.custom`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/module-federation.test.js b/packages/rspack-dev-server/tests/e2e/module-federation.test.js deleted file mode 100644 index 20b86eb8b6a..00000000000 --- a/packages/rspack-dev-server/tests/e2e/module-federation.test.js +++ /dev/null @@ -1,296 +0,0 @@ -"use strict"; - -const requireFromString = require("require-from-string"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const simpleConfig = require("../fixtures/module-federation-config/webpack.config"); -const objectEntryConfig = require("../fixtures/module-federation-config/webpack.object-entry.config"); -const multiConfig = require("../fixtures/module-federation-config/webpack.multi.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["module-federation"]; -const pluginConfig = require("../fixtures/module-federation-config/webpack.plugin"); - -describe("Module federation", () => { - describe("should work with simple multi-entry config", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(simpleConfig); - server = new Server({ port }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should use the last entry export", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - const textContent = await response.text(); - - expect(textContent).toContain("entry1"); - - let exports; - - expect(() => { - exports = requireFromString(textContent); - }).not.toThrow(); - - expect(exports).toEqual("entry2"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("should work with object multi-entry config", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(objectEntryConfig); - server = new Server({ port }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should use the last entry export", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - const textContent = await response.text(); - - expect(textContent).toContain("entry1"); - - let exports; - - expect(() => { - exports = requireFromString(textContent); - }).not.toThrow(); - - expect(exports).toEqual("entry2"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should support the named entry export", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo.js`, { - waitUntil: "networkidle0" - }); - - const textContent = await response.text(); - - expect(textContent).not.toContain("entry2"); - - let exports; - - expect(() => { - exports = requireFromString(textContent); - }).not.toThrow(); - - expect(exports).toEqual("entry1"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("should work with multi compiler config", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(multiConfig); - server = new Server({ port }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should use the last entry export", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - const textContent = await response.text(); - - expect(textContent).toContain("entry1"); - - let exports; - - expect(() => { - exports = requireFromString(textContent); - }).not.toThrow(); - - expect(exports).toEqual("entry2"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("should use plugin", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(pluginConfig); - server = new Server({ port }, compiler); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should contain hot script in remoteEntry.js", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/remoteEntry.js`, - { - waitUntil: "networkidle0" - } - ); - - const remoteEntryTextContent = await response.text(); - - expect(remoteEntryTextContent).toMatch(/rspack\/hot\/dev-server\.js/); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should contain hot script in main.js", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - const mainEntryTextContent = await response.text(); - - expect(mainEntryTextContent).toMatch(/rspack\/hot\/dev-server\.js/); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/multi-compiler.test.js b/packages/rspack-dev-server/tests/e2e/multi-compiler.test.js deleted file mode 100644 index 38575657cbf..00000000000 --- a/packages/rspack-dev-server/tests/e2e/multi-compiler.test.js +++ /dev/null @@ -1,778 +0,0 @@ -"use strict"; - -const path = require("path"); -const fs = require("graceful-fs"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const oneWebTargetConfiguration = require("../fixtures/multi-compiler-one-configuration/webpack.config"); -const twoWebTargetConfiguration = require("../fixtures/multi-compiler-two-configurations/webpack.config"); -const universalConfiguration = require("../fixtures/universal-compiler-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["multi-compiler"]; - -describe("multi compiler", () => { - it(`should work with one web target configuration and do nothing`, async () => { - const compiler = webpack(oneWebTargetConfiguration); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with web target configurations and do nothing`, async () => { - const compiler = webpack(twoWebTargetConfiguration); - const devServerOptions = { - port - }; - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - let pageErrors = []; - let consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - - pageErrors = []; - consoleMessages = []; - - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with web target configurations when hot and live reloads are enabled, and do hot reload by default when changing own entries`, async () => { - const compiler = webpack(twoWebTargetConfiguration); - const devServerOptions = { - port, - hot: true, - liveReload: true - }; - const pathToOneEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/one.js" - ); - const originalOneEntryContent = fs.readFileSync(pathToOneEntry); - const pathToTwoEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/two.js" - ); - const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - let pageErrors = []; - let consoleMessages = []; - - page - .on("console", message => { - let text = message.text(); - - if (/Error: Aborted because/.test(text)) { - const splittedText = text.split("\n"); - - text = `${splittedText[0]}\n${splittedText[1]}\n `; - } - - consoleMessages.push(text); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - - pageErrors = []; - consoleMessages = []; - - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToOneEntry, originalOneEntryContent); - fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); - } - }); - - it(`should work with web target configurations when only hot reload is enabled, and do hot reload when changing own entries`, async () => { - const compiler = webpack(twoWebTargetConfiguration); - const devServerOptions = { - port, - hot: true, - liveReload: false - }; - const pathToOneEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/one.js" - ); - const originalOneEntryContent = fs.readFileSync(pathToOneEntry); - const pathToTwoEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/two.js" - ); - const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - let pageErrors = []; - let consoleMessages = []; - - page - .on("console", message => { - let text = message.text(); - - if (/Error: Aborted because/.test(text)) { - const splittedText = text.split("\n"); - - text = `${splittedText[0]}\n${splittedText[1]}\n `; - } - - consoleMessages.push(text); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - - pageErrors = []; - consoleMessages = []; - - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToOneEntry, originalOneEntryContent); - fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); - } - }); - - it(`should work with web target configurations when only live reload is enabled, and do live reload when changing own entries`, async () => { - const compiler = webpack(twoWebTargetConfiguration); - const devServerOptions = { - port, - hot: false, - liveReload: true - }; - const pathToOneEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/one.js" - ); - const originalOneEntryContent = fs.readFileSync(pathToOneEntry); - const pathToTwoEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/two.js" - ); - const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - let pageErrors = []; - let consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - - pageErrors = []; - consoleMessages = []; - - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToOneEntry, originalOneEntryContent); - fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); - } - }); - - it(`should work with web target configurations when only live reload is enabled and do live reload when changing other entries`, async () => { - const compiler = webpack(twoWebTargetConfiguration); - const devServerOptions = { - port, - hot: false, - liveReload: true - }; - const pathToOneEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/one.js" - ); - const originalOneEntryContent = fs.readFileSync(pathToOneEntry); - const pathToTwoEntry = path.resolve( - __dirname, - "../fixtures/multi-compiler-two-configurations/two.js" - ); - const originalTwoEntryContent = fs.readFileSync(pathToTwoEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - let pageErrors = []; - let consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/one-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToTwoEntry, `${originalTwoEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - - pageErrors = []; - consoleMessages = []; - - await page.goto(`http://127.0.0.1:${port}/two-main.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync(pathToOneEntry, `${originalOneEntryContent}// comment`); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToOneEntry, originalOneEntryContent); - fs.writeFileSync(pathToTwoEntry, originalTwoEntryContent); - } - }); - - it("should work with universal configuration and do nothing", async () => { - const compiler = webpack(universalConfiguration); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - const pageErrors = []; - const consoleMessages = []; - try { - const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, - { - waitUntil: "networkidle0" - } - ); - - const serverResponseText = await serverResponse.text(); - - expect(serverResponseText).toContain("Hello from the server"); - expect(serverResponseText).not.toContain("WebsocketServer"); - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/browser.html`, { - waitUntil: "networkidle0" - }); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it(`should work with universal configuration when hot and live reloads are enabled, and do hot reload for browser compiler by default when browser entry changed`, async () => { - const compiler = webpack(universalConfiguration); - const devServerOptions = { - port, - hot: true, - liveReload: true - }; - const pathToBrowserEntry = path.resolve( - __dirname, - "../fixtures/universal-compiler-config/browser.js" - ); - const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); - const pathToServerEntry = path.resolve( - __dirname, - "../fixtures/universal-compiler-config/server.js" - ); - const originalServerEntryContent = fs.readFileSync(pathToServerEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, - { - waitUntil: "networkidle0" - } - ); - - const serverResponseText = await serverResponse.text(); - - expect(serverResponseText).toContain("Hello from the server"); - expect(serverResponseText).not.toContain("WebsocketServer"); - - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - let text = message.text(); - - if (/Error: Aborted because/.test(text)) { - const splittedText = text.split("\n"); - - text = `${splittedText[0]}\n${splittedText[1]}\n `; - } - - consoleMessages.push(text); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/browser.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync( - pathToBrowserEntry, - `${originalBrowserEntryContent}// comment` - ); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); - fs.writeFileSync(pathToServerEntry, originalServerEntryContent); - } - }); - - it(`should work with universal configuration when only hot reload is enabled, and do hot reload for browser compiler when browser entry changed`, async () => { - const compiler = webpack(universalConfiguration); - const devServerOptions = { - port, - hot: true, - liveReload: false - }; - const pathToBrowserEntry = path.resolve( - __dirname, - "../fixtures/universal-compiler-config/browser.js" - ); - const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, - { - waitUntil: "networkidle0" - } - ); - - const serverResponseText = await serverResponse.text(); - - expect(serverResponseText).toContain("Hello from the server"); - expect(serverResponseText).not.toContain("WebsocketServer"); - - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - let text = message.text(); - - if (/Error: Aborted because/.test(text)) { - const splittedText = text.split("\n"); - - text = `${splittedText[0]}\n${splittedText[1]}\n `; - } - - consoleMessages.push(text); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/browser.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync( - pathToBrowserEntry, - `${originalBrowserEntryContent}// comment` - ); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); - } - }); - - it(`should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing browser and server entries`, async () => { - const compiler = webpack(universalConfiguration); - const devServerOptions = { - port, - hot: false, - liveReload: true - }; - const pathToBrowserEntry = path.resolve( - __dirname, - "../fixtures/universal-compiler-config/browser.js" - ); - const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); - const pathToServerEntry = path.resolve( - __dirname, - "../fixtures/universal-compiler-config/server.js" - ); - const originalServerEntryContent = fs.readFileSync(pathToServerEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, - { - waitUntil: "networkidle0" - } - ); - - const serverResponseText = await serverResponse.text(); - - expect(serverResponseText).toContain("Hello from the server"); - expect(serverResponseText).not.toContain("WebsocketServer"); - - let pageErrors = []; - let consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/browser.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync( - pathToBrowserEntry, - `${originalBrowserEntryContent}// comment` - ); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - - pageErrors = []; - consoleMessages = []; - - await page.goto(`http://127.0.0.1:${port}/browser.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync( - pathToServerEntry, - `${originalServerEntryContent}// comment` - ); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); - fs.writeFileSync(pathToServerEntry, originalServerEntryContent); - } - }); - - it(`should work with universal configuration when only live reload is enabled, and do live reload for browser compiler when changing server and browser entries`, async () => { - const compiler = webpack(universalConfiguration); - const devServerOptions = { - port, - hot: false, - liveReload: true - }; - const pathToBrowserEntry = path.resolve( - __dirname, - "../fixtures/universal-compiler-config/browser.js" - ); - const originalBrowserEntryContent = fs.readFileSync(pathToBrowserEntry); - const pathToServerEntry = path.resolve( - __dirname, - "../fixtures/universal-compiler-config/server.js" - ); - const originalServerEntryContent = fs.readFileSync(pathToServerEntry); - - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const serverResponse = await page.goto( - `http://127.0.0.1:${port}/server.js`, - { - waitUntil: "networkidle0" - } - ); - - const serverResponseText = await serverResponse.text(); - - expect(serverResponseText).toContain("Hello from the server"); - expect(serverResponseText).not.toContain("WebsocketServer"); - - let pageErrors = []; - let consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/browser.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync( - pathToServerEntry, - `${originalServerEntryContent}// comment` - ); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - - pageErrors = []; - consoleMessages = []; - - await page.goto(`http://127.0.0.1:${port}/browser.html`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync( - pathToBrowserEntry, - `${originalBrowserEntryContent}// comment` - ); - - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - fs.writeFileSync(pathToBrowserEntry, originalBrowserEntryContent); - fs.writeFileSync(pathToServerEntry, originalServerEntryContent); - } - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/on-listening.test.js b/packages/rspack-dev-server/tests/e2e/on-listening.test.js deleted file mode 100644 index 66aa909e19c..00000000000 --- a/packages/rspack-dev-server/tests/e2e/on-listening.test.js +++ /dev/null @@ -1,127 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["on-listening-option"]; - -describe("onListening option", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - let onListeningIsRunning = false; - - beforeEach(async () => { - compiler = webpack(config); - server = new Server( - { - onListening: devServer => { - if (!devServer) { - throw new Error("webpack-dev-server is not defined"); - } - - onListeningIsRunning = true; - - devServer.app.get("/listening/some/path", (_, response) => { - response.send("listening"); - }); - - devServer.app.post("/listening/some/path", (_, response) => { - response.send("listening POST"); - }); - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to /listening/some/path route", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/listening/some/path`, - { - waitUntil: "networkidle0" - } - ); - - expect(onListeningIsRunning).toBe(true); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle POST request to /listening/some/path route", async () => { - await page.setRequestInterception(true); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - - interceptedRequest.continue({ method: "POST" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/listening/some/path`, - { - waitUntil: "networkidle0" - } - ); - - expect(onListeningIsRunning).toBe(true); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/overlay.test.js b/packages/rspack-dev-server/tests/e2e/overlay.test.js deleted file mode 100644 index c503f1ed0d0..00000000000 --- a/packages/rspack-dev-server/tests/e2e/overlay.test.js +++ /dev/null @@ -1,1991 +0,0 @@ -"use strict"; - -const path = require("path"); -const fs = require("graceful-fs"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const waitForExpect = require("wait-for-expect"); -const config = require("../fixtures/overlay-config/webpack.config"); -const trustedTypesConfig = require("../fixtures/overlay-config/trusted-types.webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").overlay; -require("../helpers/normalize"); - -class ErrorPlugin { - constructor(message, skipCounter) { - this.message = - message || "Error from compilation. Can't find 'test' module."; - this.skipCounter = skipCounter; - this.counter = 0; - } - - apply(compiler) { - compiler.hooks.thisCompilation.tap("errors-webpack-plugin", compilation => { - if ( - typeof this.skipCounter !== "undefined" && - this.counter !== this.skipCounter - ) { - this.counter += 1; - - return; - } - - compilation.errors.push(new Error(this.message)); - }); - } -} - -class WarningPlugin { - constructor(message, skipCounter) { - this.message = message || "Warning from compilation"; - this.skipCounter = skipCounter; - this.counter = 0; - } - - apply(compiler) { - compiler.hooks.thisCompilation.tap( - "warnings-webpack-plugin", - compilation => { - if ( - typeof this.skipCounter !== "undefined" && - this.counter !== this.skipCounter - ) { - this.counter += 1; - - return; - } - - compilation.warnings.push(new Error(this.message)); - } - ); - } -} - -const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); - -let prettier; -let prettierHTML; -let prettierCSS; - -describe("overlay", () => { - beforeAll(async () => { - // Due problems with ESM modules for Node.js@18 - // TODO replace it on import/require when Node.js@18 will be dropped - prettier = require("../../node_modules/prettier/standalone"); - prettierHTML = require("../../node_modules/prettier/plugins/html"); - prettierCSS = require("../../node_modules/prettier/plugins/postcss"); - }); - - it("should show a warning for initial compilation", async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show an error for initial compilation", async () => { - const compiler = webpack(config); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show a warning and error for initial compilation", async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - new WarningPlugin().apply(compiler); - new ErrorPlugin().apply(compiler); - new ErrorPlugin().apply(compiler); - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show an ansi formatted error for initial compilation", async () => { - const compiler = webpack(config); - - new ErrorPlugin( - "  18 | Render ansi formatted text" - ).apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show a warning and error for initial compilation and protects against xss", async () => { - const compiler = webpack(config); - - new WarningPlugin("strong").apply(compiler); - new ErrorPlugin("strong").apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show initially, then show on an error, then hide on fix", async () => { - const compiler = webpack(config); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - let pageHtml = await page.evaluate(() => document.body.outerHTML); - let overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html initial"); - - const pathToFile = path.resolve( - __dirname, - "../fixtures/overlay-config/foo.js" - ); - const originalCode = fs.readFileSync(pathToFile); - - fs.writeFileSync(pathToFile, "`;"); - - await page.waitForSelector("#webpack-dev-server-client-overlay"); - - overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - pageHtml = await page.evaluate(() => document.body.outerHTML); - - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html with error"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - - fs.writeFileSync(pathToFile, originalCode); - - await page.waitForSelector("#webpack-dev-server-client-overlay", { - hidden: true - }); - - pageHtml = await page.evaluate(() => document.body.outerHTML); - overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html after fix error"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show initially, then show on an error, then show other error, then hide on fix", async () => { - const compiler = webpack(config); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - let pageHtml = await page.evaluate(() => document.body.outerHTML); - let overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html initial"); - - const pathToFile = path.resolve( - __dirname, - "../fixtures/overlay-config/foo.js" - ); - const originalCode = fs.readFileSync(pathToFile); - - fs.writeFileSync(pathToFile, "`;"); - - await page.waitForSelector("#webpack-dev-server-client-overlay"); - - overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - pageHtml = await page.evaluate(() => document.body.outerHTML); - - let overlayFrame = await overlayHandle.contentFrame(); - let overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html with error"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - - fs.writeFileSync(pathToFile, "`;a"); - - await page.waitForSelector("#webpack-dev-server-client-overlay", { - hidden: true - }); - await page.waitForSelector("#webpack-dev-server-client-overlay"); - - overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - pageHtml = await page.evaluate(() => document.body.outerHTML); - - overlayFrame = await overlayHandle.contentFrame(); - overlayHtml = await overlayFrame.evaluate(() => document.body.outerHTML); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html with other error"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - - fs.writeFileSync(pathToFile, originalCode); - - await page.waitForSelector("#webpack-dev-server-client-overlay", { - hidden: true - }); - - pageHtml = await page.evaluate(() => document.body.outerHTML); - overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html after fix error"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show initially, then show on an error and allow to close", async () => { - const compiler = webpack(config); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - let pageHtml = await page.evaluate(() => document.body.outerHTML); - let overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html initial"); - - const pathToFile = path.resolve( - __dirname, - "../fixtures/overlay-config/foo.js" - ); - const originalCode = fs.readFileSync(pathToFile); - - fs.writeFileSync(pathToFile, "`;"); - - await page.waitForSelector("#webpack-dev-server-client-overlay"); - - overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - pageHtml = await page.evaluate(() => document.body.outerHTML); - - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html with error"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - - const frame = await page - .frames() - .find(item => item.name() === "webpack-dev-server-client-overlay"); - - const buttonHandle = await frame.$("button"); - - await buttonHandle.click(); - - await page.waitForSelector("#webpack-dev-server-client-overlay", { - hidden: true - }); - - pageHtml = await page.evaluate(() => document.body.outerHTML); - overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html after close"); - - fs.writeFileSync(pathToFile, originalCode); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should open editor when error with file info is clicked", async () => { - const mockLaunchEditorCb = jest.fn(); - jest.mock("launch-editor", () => mockLaunchEditorCb); - - const compiler = webpack(config); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const pathToFile = path.resolve( - __dirname, - "../fixtures/overlay-config/foo.js" - ); - const originalCode = fs.readFileSync(pathToFile); - - fs.writeFileSync(pathToFile, "`;"); - - await page.waitForSelector("#webpack-dev-server-client-overlay"); - - const frame = page - .frames() - .find(item => item.name() === "webpack-dev-server-client-overlay"); - - const errorHandle = await frame.$("[data-can-open]"); - - await errorHandle.click(); - - await waitForExpect(() => { - expect(mockLaunchEditorCb).toHaveBeenCalledTimes(1); - }); - - fs.writeFileSync(pathToFile, originalCode); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should not show a warning when "client.overlay" is "false"', async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: false - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should not show a warning when "client.overlay.warnings" is "false"', async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - warnings: false - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show warning when it is filtered", async () => { - const compiler = webpack(config); - - new WarningPlugin("My special warning").apply(compiler); - - const server = new Server( - { - port, - client: { - overlay: { - warnings: error => { - // error is string in webpack 4 - const message = typeof error === "string" ? error : error.message; - return !message.includes("My special warning"); - } - } - } - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show warning when it is not filtered", async () => { - const compiler = webpack(config); - - new WarningPlugin("Unfiltered warning").apply(compiler); - - const server = new Server( - { - port, - client: { - overlay: { - warnings: () => true - } - } - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should show a warning when "client.overlay" is "true"', async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: true - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should show a warning when "client.overlay.warnings" is "true"', async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - warnings: true - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should show a warning when "client.overlay.errors" is "true"', async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - errors: true - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should not show an error when "client.overlay" is "false"', async () => { - const compiler = webpack(config); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: false - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should not show an error when "client.overlay.errors" is "false"', async () => { - const compiler = webpack(config); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - errors: false - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show error when it is filtered", async () => { - const compiler = webpack(config); - - new ErrorPlugin("My special error").apply(compiler); - - const server = new Server( - { - port, - client: { - overlay: { - errors: error => { - // error is string in webpack 4 - const message = typeof error === "string" ? error : error.message; - - return !message.includes("My special error"); - } - } - } - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show error when it is not filtered", async () => { - const compiler = webpack(config); - - new ErrorPlugin("Unfiltered error").apply(compiler); - - const server = new Server( - { - port, - client: { - overlay: { - errors: () => true - } - } - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should show an error when "client.overlay" is "true"', async () => { - const compiler = webpack(config); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: true - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show overlay when Trusted Types are enabled", async () => { - const compiler = webpack(trustedTypesConfig); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - trustedTypesPolicyName: "webpack#dev-overlay" - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message.text()); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - consoleMessages.filter(item => - /requires 'TrustedHTML' assignment/.test(item) - ) - ).toHaveLength(0); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show overlay when Trusted Types are enabled and the \"require-trusted-types-for 'script'\" header was used", async () => { - const compiler = webpack(trustedTypesConfig); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - headers: [ - { - key: "Content-Security-Policy", - value: "require-trusted-types-for 'script'" - } - ], - client: { - overlay: { - trustedTypesPolicyName: "webpack#dev-overlay" - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message.text()); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - consoleMessages.filter(item => - /requires 'TrustedHTML' assignment/.test(item) - ) - ).toHaveLength(0); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show overlay when Trusted Types are enabled, but policy is not allowed", async () => { - const compiler = webpack(trustedTypesConfig); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - trustedTypesPolicyName: "disallowed-policy" - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - expect(overlayHandle).toBe(null); - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should show an error when "client.overlay.errors" is "true"', async () => { - const compiler = webpack(config); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - errors: true - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should show an error when "client.overlay.warnings" is "true"', async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { - port, - client: { - overlay: { - warnings: true - } - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show a warning and hide them after closing connection", async () => { - const compiler = webpack(config); - - new WarningPlugin().apply(compiler); - - const devServerOptions = { port }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message.text()); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - - await server.stop(); - - await new Promise(resolve => { - const interval = setInterval(() => { - if (consoleMessages.includes("[webpack-dev-server] Disconnected!")) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); - - const pageHtmlAfterClose = await page.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtmlAfterClose, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - } - }); - - it("should show an error after invalidation", async () => { - const compiler = webpack(config); - - new ErrorPlugin("Error from compilation", 1).apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - await new Promise(resolve => { - server.middleware.invalidate(() => { - resolve(); - }); - }); - - await new Promise(resolve => { - server.middleware.waitUntilValid(() => { - resolve(); - }); - }); - - // Delay for the overlay to appear - await delay(1000); - - await page.waitForSelector("#webpack-dev-server-client-overlay"); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show a warning after invalidation", async () => { - const compiler = webpack(config); - - new WarningPlugin("Warning from compilation", 1).apply(compiler); - - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - await new Promise(resolve => { - server.middleware.invalidate(() => { - resolve(); - }); - }); - - await new Promise(resolve => { - server.middleware.waitUntilValid(() => { - resolve(); - }); - }); - - // Delay for the overlay to appear - await delay(1000); - - await page.waitForSelector("#webpack-dev-server-client-overlay"); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show error for uncaught runtime error", async () => { - const compiler = webpack(config); - - const server = new Server( - { - port - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - await page.addScriptTag({ - content: `(function throwError() { - throw new Error('Injected error'); - })();` - }); - - // Delay for the overlay to appear - await delay(1000); - - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show filtered runtime error", async () => { - const compiler = webpack(config); - - const server = new Server( - { - port, - client: { - overlay: { - runtimeErrors: error => error && !/Injected/.test(error.message) - } - } - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - await page.addScriptTag({ - content: `(function throwError() { - throw new Error('Injected error'); - })();` - }); - - // Delay for the overlay to appear - await delay(1000); - - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should show error for uncaught promise rejection", async () => { - const compiler = webpack(config); - - const server = new Server( - { - port - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - await page.addScriptTag({ - content: `(function throwError() { - setTimeout(function () { - Promise.reject(new Error('Async error')); - }, 0); - })();` - }); - - // Delay for the overlay to appear - await delay(1000); - - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should not show filtered promise rejection", async () => { - const compiler = webpack(config); - - const server = new Server( - { - port, - client: { - overlay: { - runtimeErrors: error => !/Injected/.test(error.message) - } - } - }, - compiler - ); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - await page.addScriptTag({ - content: `(function throwError() { - setTimeout(function () { - Promise.reject(new Error('Injected async error')); - }, 0); - })();` - }); - - // Delay for the overlay to appear - await delay(1000); - - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - - expect(overlayHandle).toBe(null); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should show overlay when "Content-Security-Policy" is "default-src \'self\'" was used', async () => { - const compiler = webpack({ ...config, devtool: false }); - - new ErrorPlugin().apply(compiler); - - const devServerOptions = { - port, - headers: [ - { - key: "Content-Security-Policy", - value: "default-src 'self'" - } - ] - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message.text()); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - // Delay for the overlay to appear - await delay(1000); - - const pageHtml = await page.evaluate(() => document.body.outerHTML); - const overlayHandle = await page.$("#webpack-dev-server-client-overlay"); - const overlayFrame = await overlayHandle.contentFrame(); - const overlayHtml = await overlayFrame.evaluate( - () => document.body.outerHTML - ); - - expect( - await prettier.format(pageHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("page html"); - expect( - await prettier.format(overlayHtml, { - parser: "html", - plugins: [prettierHTML, prettierCSS] - }) - ).toMatchSnapshot("overlay html"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/port.test.js b/packages/rspack-dev-server/tests/e2e/port.test.js deleted file mode 100644 index bebc3c8f6b3..00000000000 --- a/packages/rspack-dev-server/tests/e2e/port.test.js +++ /dev/null @@ -1,115 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").port; - -describe("port", () => { - const ports = [ - "", - // eslint-disable-next-line no-undefined - undefined, - "auto", - port, - `${port}`, - 0, - "-1", - "99999" - ]; - - for (const testedPort of ports) { - it(`should work using "${testedPort}" port `, async () => { - const compiler = webpack(config); - const devServerOptions = {}; - - let usedPort; - - if ( - testedPort === "" || - typeof testedPort === "undefined" - ) { - process.env.WEBPACK_DEV_SERVER_BASE_PORT = port; - usedPort = port; - } else if (testedPort === "auto") { - process.env.WEBPACK_DEV_SERVER_BASE_PORT = port; - devServerOptions.port = testedPort; - usedPort = port; - } else { - devServerOptions.port = testedPort; - usedPort = testedPort; - } - - const server = new Server(devServerOptions, compiler); - - let errored; - - try { - await server.start(); - } catch (error) { - errored = error; - } - - if (testedPort === "-1" || testedPort === "99999") { - const errorMessageRegExp = new RegExp( - `options.port should be >= 0 and < 65536` - ); - - try { - expect(errored.message).toMatch(errorMessageRegExp); - } catch (error) { - throw error; - } finally { - await server.stop(); - } - - return; - } - - const address = server.server.address(); - - if (testedPort === 0) { - expect(typeof address.port).toBe("number"); - } else { - expect(address.port).toBe(Number(usedPort)); - } - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${address.port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - - if ( - testedPort === "" || - typeof testedPort === "undefined" - ) { - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - } - }); - } -}); diff --git a/packages/rspack-dev-server/tests/e2e/progress.test.js b/packages/rspack-dev-server/tests/e2e/progress.test.js deleted file mode 100644 index 87017a55167..00000000000 --- a/packages/rspack-dev-server/tests/e2e/progress.test.js +++ /dev/null @@ -1,90 +0,0 @@ -"use strict"; - -const path = require("path"); -const fs = require("graceful-fs"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const reloadConfig = require("../fixtures/reload-config-2/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").progress; - -const cssFilePath = path.resolve( - __dirname, - "../fixtures/reload-config-2/main.css" -); - -describe("progress", () => { - it("should work and log progress in a browser console", async () => { - fs.writeFileSync(cssFilePath, "body { background-color: rgb(0, 0, 255); }"); - - const compiler = webpack(reloadConfig); - const devServerOptions = { - port, - client: { - progress: true - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - try { - const { page, browser } = await runBrowser(); - - const consoleMessages = []; - - try { - let doHotUpdate = false; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - - if (/\.hot-update\.(json|js)$/.test(interceptedRequest.url())) { - doHotUpdate = true; - } - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - fs.writeFileSync( - cssFilePath, - "body { background-color: rgb(255, 0, 0); }" - ); - - await new Promise(resolve => { - const timer = setInterval(() => { - if (doHotUpdate) { - clearInterval(timer); - - resolve(); - } - }, 100); - }); - } catch (error) { - throw error; - } finally { - await browser.close(); - } - - const progressConsoleMessage = consoleMessages.filter(message => - /^\[webpack-dev-server\] (\[[a-zA-Z]+\] )?[0-9]{1,3}% - /.test( - message.text() - ) - ); - - expect(progressConsoleMessage.length > 0).toBe(true); - } catch (error) { - throw error; - } finally { - fs.unlinkSync(cssFilePath); - - await server.stop(); - } - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/range-header.test.js b/packages/rspack-dev-server/tests/e2e/range-header.test.js deleted file mode 100644 index 7679cecd0fa..00000000000 --- a/packages/rspack-dev-server/tests/e2e/range-header.test.js +++ /dev/null @@ -1,111 +0,0 @@ -"use strict"; - -const request = require("supertest"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/static-config/webpack.config"); -const port = require("../helpers/ports-map")["range-header"]; - -describe("'Range' header", () => { - let compiler; - let server; - - beforeAll(async () => { - compiler = webpack(config); - - server = new Server({ port }, compiler); - - await server.start(); - }); - - afterAll(async () => { - await server.stop(); - }); - - it('should work with "Range" header using "GET" method', async () => { - const response = await request(server.app).get("/main.js"); - - expect(response.status).toBe(200); - expect(response.headers["content-type"]).toBe( - "application/javascript; charset=utf-8" - ); - expect(response.headers["accept-ranges"]).toBe("bytes"); - - const responseContent = response.text; - const responseRange = await request(server.app) - .get("/main.js") - .set("Range", "bytes=0-499"); - - expect(responseRange.status).toBe(206); - expect(responseRange.headers["content-type"]).toBe( - "application/javascript; charset=utf-8" - ); - expect(responseRange.headers["content-length"]).toBe("500"); - expect(responseRange.headers["content-range"]).toMatch(/^bytes 0-499\//); - expect(responseRange.text).toBe(responseContent.slice(0, 500)); - expect(responseRange.text.length).toBe(500); - }); - - it('should work with "Range" header using "HEAD" method', async () => { - const response = await request(server.app).head("/main.js"); - - expect(response.status).toBe(200); - expect(response.headers["content-type"]).toBe( - "application/javascript; charset=utf-8" - ); - expect(response.headers["accept-ranges"]).toBe("bytes"); - - const responseRange = await request(server.app) - .head("/main.js") - .set("Range", "bytes=0-499"); - - expect(responseRange.status).toBe(206); - expect(responseRange.headers["content-type"]).toBe( - "application/javascript; charset=utf-8" - ); - expect(responseRange.headers["content-length"]).toBe("500"); - expect(responseRange.headers["content-range"]).toMatch(/^bytes 0-499\//); - }); - - it('should work with unsatisfiable "Range" header using "GET" method', async () => { - const response = await request(server.app).get("/main.js"); - - expect(response.status).toBe(200); - expect(response.headers["content-type"]).toBe( - "application/javascript; charset=utf-8" - ); - expect(response.headers["accept-ranges"]).toBe("bytes"); - - const responseRange = await request(server.app) - .get("/main.js") - .set("Range", "bytes=99999999999-"); - - expect(responseRange.status).toBe(416); - expect(responseRange.headers["content-type"]).toBe( - "text/html; charset=utf-8" - ); - expect(responseRange.headers["content-range"]).toMatch(/^bytes \*\//); - }); - - it('should work with malformed "Range" header using "GET" method', async () => { - const response = await request(server.app).get("/main.js"); - - expect(response.status).toBe(200); - expect(response.headers["content-type"]).toBe( - "application/javascript; charset=utf-8" - ); - expect(response.headers["accept-ranges"]).toBe("bytes"); - - const responseContent = response.text; - const responseRange = await request(server.app) - .get("/main.js") - .set("Range", "bytes"); - - expect(responseRange.status).toBe(200); - expect(responseRange.headers["content-type"]).toBe( - "application/javascript; charset=utf-8" - ); - expect(responseRange.text).toBe(responseContent); - expect(responseRange.text.length).toBe(responseContent.length); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/server-and-client-transport.test.js b/packages/rspack-dev-server/tests/e2e/server-and-client-transport.test.js deleted file mode 100644 index 25dde36936c..00000000000 --- a/packages/rspack-dev-server/tests/e2e/server-and-client-transport.test.js +++ /dev/null @@ -1,620 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const WebsocketServer = require("webpack-dev-server/lib/servers/WebsocketServer"); -const defaultConfig = require("../fixtures/provide-plugin-default/webpack.config"); -const sockjsConfig = require("../fixtures/provide-plugin-sockjs-config/webpack.config"); -const wsConfig = require("../fixtures/provide-plugin-ws-config/webpack.config"); -const customConfig = require("../fixtures/provide-plugin-custom/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["server-and-client-transport"]; - -describe("server and client transport", () => { - it('should use default web socket server ("ws")', async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use "ws" web socket server when specify "ws" value', async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - webSocketServer: "ws" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use "ws" web socket server when specify "ws" value using object', async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - webSocketServer: { - type: "ws" - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use "sockjs" web socket server when specify "sockjs" value', async () => { - const compiler = webpack(sockjsConfig); - const devServerOptions = { - port, - webSocketServer: "sockjs" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use "sockjs" web socket server when specify "sockjs" value using object', async () => { - const compiler = webpack(sockjsConfig); - const devServerOptions = { - port, - webSocketServer: { - type: "sockjs" - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should use custom web socket server when specify class", async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "ws" - }, - webSocketServer: WebsocketServer - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should use custom web socket server when specify class using object", async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "ws" - }, - webSocketServer: { - type: WebsocketServer - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should use custom web socket server when specify path to class", async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "ws" - }, - webSocketServer: require.resolve( - "webpack-dev-server/lib/servers/WebsocketServer" - ) - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should use custom web socket server when specify path to class using object", async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "ws" - }, - webSocketServer: { - type: require.resolve("webpack-dev-server/lib/servers/WebsocketServer") - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should throw an error on wrong path", async () => { - expect.assertions(1); - - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - webSocketServer: { - type: "/bad/path/to/implementation" - } - }; - const server = new Server(devServerOptions, compiler); - - try { - await server.start(); - } catch (error) { - expect(error.message).toMatchSnapshot(); - } finally { - await server.stop(); - } - }); - - it('should use "sockjs" transport, when web socket server is not specify', async () => { - const compiler = webpack(sockjsConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "sockjs" - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/main.js`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use "ws" transport, when web socket server is not specify', async () => { - const compiler = webpack(wsConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "ws" - } - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use "sockjs" transport and "sockjs" web socket server', async () => { - const compiler = webpack(sockjsConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "sockjs" - }, - webSocketServer: "sockjs" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use "ws" transport and "ws" web socket server', async () => { - const compiler = webpack(wsConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "ws" - }, - webSocketServer: "ws" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it('should use custom transport and "sockjs" web socket server', async () => { - const compiler = webpack(customConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: require.resolve( - "../fixtures/custom-client/CustomSockJSClient" - ) - }, - webSocketServer: "sockjs" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - const isCorrectTransport = await page.evaluate( - () => window.injectedClient === window.expectedClient - ); - - expect(isCorrectTransport).toBe(true); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it("should throw an error on invalid path to server transport", async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - webSocketServer: { - type: "invalid/path" - } - }; - const server = new Server(devServerOptions, compiler); - await expect(async () => { - await server.start(); - }).rejects.toThrowErrorMatchingSnapshot(); - - await server.stop(); - }); - - it("should throw an error on invalid path to client transport", async () => { - const compiler = webpack(defaultConfig); - const devServerOptions = { - port, - client: { - webSocketTransport: "invalid/path" - } - }; - const server = new Server(devServerOptions, compiler); - await expect(async () => { - await server.start(); - }).rejects.toThrowErrorMatchingSnapshot(); - - await server.stop(); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/server.test.js b/packages/rspack-dev-server/tests/e2e/server.test.js deleted file mode 100644 index ed6ef655495..00000000000 --- a/packages/rspack-dev-server/tests/e2e/server.test.js +++ /dev/null @@ -1,1441 +0,0 @@ -"use strict"; - -const https = require("https"); -const path = require("path"); -const fs = require("graceful-fs"); -const request = require("supertest"); -const spdy = require("spdy"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/static-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const { skipTestOnWindows } = require("../helpers/conditional-test"); -const customHTTP = require("../helpers/custom-http"); -const normalizeOptions = require("../helpers/normalize-options"); -const port = require("../helpers/ports-map")["server-option"]; - -const httpsCertificateDirectory = path.resolve( - __dirname, - "../fixtures/https-certificate" -); - -const staticDirectory = path.resolve( - __dirname, - "../fixtures/static-config/public" -); - -describe("server option", () => { - describe("as string", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - describe("http", () => { - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: "http", - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - const HTTPVersion = await page.evaluate( - () => performance.getEntries()[0].nextHopProtocol - ); - - expect(HTTPVersion).not.toEqual("h2"); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("custom-http", () => { - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: path.resolve(__dirname, "../helpers/custom-http.js"), - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - const HTTPVersion = await page.evaluate( - () => performance.getEntries()[0].nextHopProtocol - ); - - expect(HTTPVersion).not.toEqual("h2"); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("https", () => { - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: "https", - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - const HTTPVersion = await page.evaluate( - () => performance.getEntries()[0].nextHopProtocol - ); - - expect(HTTPVersion).not.toEqual("h2"); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("spdy", () => { - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: "spdy", - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - const HTTPVersion = await page.evaluate( - () => performance.getEntries()[0].nextHopProtocol - ); - - expect(HTTPVersion).toEqual("h2"); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - }); - - describe("as object", () => { - describe("ca, pfx, key and cert are buffer", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are array of buffers", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: [ - fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ) - ], - pfx: [ - fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ) - ], - key: [ - fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ) - ], - cert: [ - fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ) - ], - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are strings", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: fs - .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) - .toString(), - // TODO - // pfx can't be string because it is binary format - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ) - .toString(), - cert: fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ) - .toString(), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are array of strings", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: [ - fs - .readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ) - .toString() - ], - // pfx can't be string because it is binary format - pfx: [ - fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ) - ], - key: [ - fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ) - .toString() - ], - cert: [ - fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ) - .toString() - ], - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are paths to files", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: path.join(httpsCertificateDirectory, "ca.pem"), - pfx: path.join(httpsCertificateDirectory, "server.pfx"), - key: path.join(httpsCertificateDirectory, "server.key"), - cert: path.join(httpsCertificateDirectory, "server.crt"), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are array of paths to files", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: [path.join(httpsCertificateDirectory, "ca.pem")], - pfx: [path.join(httpsCertificateDirectory, "server.pfx")], - key: [path.join(httpsCertificateDirectory, "server.key")], - cert: [path.join(httpsCertificateDirectory, "server.crt")], - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are symlinks", () => { - if (skipTestOnWindows("Symlinks are not supported on Windows")) { - return; - } - - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: path.join(httpsCertificateDirectory, "ca-symlink.pem"), - pfx: path.join(httpsCertificateDirectory, "server-symlink.pfx"), - key: path.join(httpsCertificateDirectory, "server-symlink.key"), - cert: path.join( - httpsCertificateDirectory, - "server-symlink.crt" - ), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toEqual(200); - expect(await response.text()).toContain("Heyo"); - expect(consoleMessages.map(message => message.text())).toEqual([]); - expect(pageErrors).toEqual([]); - }); - }); - - describe("ca, pfx, key and cert are buffer", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are buffer, key and pfx are objects", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: [ - { - buf: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ) - } - ], - key: [ - { - pem: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ) - } - ], - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("ca, pfx, key and cert are strings, key and pfx are objects", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - ca: fs - .readFileSync(path.join(httpsCertificateDirectory, "ca.pem")) - .toString(), - pfx: [ - { - // pfx can't be string because it is binary format - buf: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ) - } - ], - key: [ - { - pem: fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ) - .toString() - } - ], - cert: fs - .readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ) - .toString(), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("allow to pass more options", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - minVersion: "TLSv1.1", - ca: fs.readFileSync( - path.join(httpsCertificateDirectory, "ca.pem") - ), - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - // puppeteer having issues accepting SSL here, throwing error net::ERR_BAD_SSL_CLIENT_AUTH_CERT, hence testing with supertest - describe('should support the "requestCert" option', () => { - let compiler; - let server; - let createServerSpy; - let req; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(https, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "https", - options: { - requestCert: true, - pfx: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.pfx") - ), - key: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.key") - ), - cert: fs.readFileSync( - path.join(httpsCertificateDirectory, "server.crt") - ), - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - req = request(server.app); - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await server.stop(); - }); - - it("should pass options to the 'https.createServer' method", async () => { - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - }); - - it("should handle GET request to index route (/)", async () => { - const response = await req.get("/"); - - expect(response.status).toMatchSnapshot("response status"); - expect(response.text).toMatchSnapshot("response text"); - }); - }); - - describe("spdy server with options", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(spdy, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: "spdy", - options: { - requestCert: false, - ca: [path.join(httpsCertificateDirectory, "ca.pem")], - pfx: [path.join(httpsCertificateDirectory, "server.pfx")], - key: [path.join(httpsCertificateDirectory, "server.key")], - cert: [path.join(httpsCertificateDirectory, "server.crt")], - passphrase: "webpack-dev-server" - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`https://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - const HTTPVersion = await page.evaluate( - () => performance.getEntries()[0].nextHopProtocol - ); - - expect(HTTPVersion).toEqual("h2"); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("https options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("custom server with options", () => { - let compiler; - let server; - let createServerSpy; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - createServerSpy = jest.spyOn(customHTTP, "createServer"); - - server = new Server( - { - static: { - directory: staticDirectory, - watch: false - }, - server: { - type: path.join(__dirname, "../helpers/custom-http.js"), - options: { - maxHeaderSize: 16384 - } - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - createServerSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to index route (/)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - const HTTPVersion = await page.evaluate( - () => performance.getEntries()[0].nextHopProtocol - ); - - expect(HTTPVersion).toEqual("http/1.1"); - expect( - normalizeOptions(createServerSpy.mock.calls[0][0]) - ).toMatchSnapshot("http options"); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/setup-exit-signals.test.js b/packages/rspack-dev-server/tests/e2e/setup-exit-signals.test.js deleted file mode 100644 index fa4420ea295..00000000000 --- a/packages/rspack-dev-server/tests/e2e/setup-exit-signals.test.js +++ /dev/null @@ -1,118 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/simple-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["setup-exit-signals-option"]; - -describe("setupExitSignals option", () => { - describe("should handle 'SIGINT' and 'SIGTERM' signals", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - let doExit; - let exitSpy; - let stopCallbackSpy; - let stdinResumeSpy; - let closeCallbackSpy; - - const signals = ["SIGINT", "SIGTERM"]; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - setupExitSignals: true, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - doExit = false; - - exitSpy = jest.spyOn(process, "exit").mockImplementation(() => { - doExit = true; - }); - - stdinResumeSpy = jest - .spyOn(process.stdin, "resume") - .mockImplementation(() => {}); - - stopCallbackSpy = jest.spyOn(server, "stopCallback"); - - if (server.compiler.close) { - closeCallbackSpy = jest.spyOn(server.compiler, "close"); - } - }); - - afterEach(async () => { - exitSpy.mockReset(); - stdinResumeSpy.mockReset(); - signals.forEach(signal => { - process.removeAllListeners(signal); - }); - process.stdin.removeAllListeners("end"); - await browser.close(); - await server.stop(); - }); - - it.each(signals)("should close and exit on %s", async signal => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - process.emit(signal); - - await new Promise(resolve => { - const interval = setInterval(() => { - if (doExit) { - expect(stopCallbackSpy.mock.calls.length).toEqual(1); - - if (server.compiler.close) { - expect(closeCallbackSpy.mock.calls.length).toEqual(1); - } - - clearInterval(interval); - - resolve(); - } - }, 100); - }); - - consoleMessages = consoleMessages.filter( - message => - !( - message.text().includes("Trying to reconnect...") || - message.text().includes("Disconnected") - ) - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/setup-middlewares.test.js b/packages/rspack-dev-server/tests/e2e/setup-middlewares.test.js deleted file mode 100644 index 2d49c543ff2..00000000000 --- a/packages/rspack-dev-server/tests/e2e/setup-middlewares.test.js +++ /dev/null @@ -1,171 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["setup-middlewares-option"]; - -describe("setupMiddlewares option", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - server = new Server( - { - setupMiddlewares: (middlewares, devServer) => { - if (!devServer) { - throw new Error("webpack-dev-server is not defined"); - } - - devServer.app.get("/setup-middleware/some/path", (_, response) => { - response.send("setup-middlewares option GET"); - }); - - devServer.app.post("/setup-middleware/some/path", (_, response) => { - response.send("setup-middlewares option POST"); - }); - - middlewares.push({ - name: "hello-world-test-two", - middleware: (req, res, next) => { - if (req.path !== "/foo/bar/baz") { - next(); - - return; - } - - res.send("Hello World without path!"); - } - }); - middlewares.push({ - name: "hello-world-test-one", - path: "/foo/bar", - middleware: (req, res) => { - res.send("Hello World with path!"); - } - }); - middlewares.push((req, res) => { - res.send("Hello World as function!"); - }); - - return middlewares; - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request to /setup-middleware/some/path route", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/setup-middleware/some/path`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - - const response1 = await page.goto(`http://127.0.0.1:${port}/foo/bar`, { - waitUntil: "networkidle0" - }); - - expect(response1.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - expect(response1.status()).toMatchSnapshot("response status"); - expect(await response1.text()).toMatchSnapshot("response text"); - - const response2 = await page.goto(`http://127.0.0.1:${port}/foo/bar/baz`, { - waitUntil: "networkidle0" - }); - - expect(response2.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - expect(response2.status()).toMatchSnapshot("response status"); - expect(await response2.text()).toMatchSnapshot("response text"); - - const response3 = await page.goto( - `http://127.0.0.1:${port}/setup-middleware/unknown`, - { - waitUntil: "networkidle0" - } - ); - - expect(response3.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - expect(response3.status()).toMatchSnapshot("response status"); - expect(await response3.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle POST request to /setup-middleware/some/path route", async () => { - await page.setRequestInterception(true); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - - interceptedRequest.continue({ method: "POST" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}/setup-middleware/some/path`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response headers content-type" - ); - expect(response.status()).toMatchSnapshot("response status"); - expect(await response.text()).toMatchSnapshot("response text"); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/static-directory.test.js b/packages/rspack-dev-server/tests/e2e/static-directory.test.js deleted file mode 100644 index 551c7c7f63d..00000000000 --- a/packages/rspack-dev-server/tests/e2e/static-directory.test.js +++ /dev/null @@ -1,686 +0,0 @@ -"use strict"; - -const path = require("path"); -const fs = require("graceful-fs"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const testServer = require("../helpers/test-server"); -const config = require("../fixtures/static-config/webpack.config"); -const port = require("../helpers/ports-map")["static-directory-option"]; -const runBrowser = require("../helpers/run-browser"); - -const staticDirectory = path.resolve(__dirname, "../fixtures/static-config"); -const publicDirectory = path.resolve(staticDirectory, "public"); -const otherPublicDirectory = path.resolve(staticDirectory, "other"); - -describe("static.directory option", () => { - describe("to directory", () => { - const nestedFile = path.resolve(publicDirectory, "assets/example.txt"); - - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - watch: true - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - fs.truncateSync(nestedFile); - }); - - it("should handle request to index route", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to other file", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/other.html`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("Watches folder recursively", done => { - // chokidar emitted a change, - // meaning it watched the file correctly - server.staticWatchers[0].on("change", () => { - done(); - }); - - // change a file manually - setTimeout(() => { - fs.writeFileSync(nestedFile, "Heyo", "utf8"); - }, 1000); - }); - - it("Watches node_modules", done => { - const filePath = path.join(publicDirectory, "node_modules", "index.html"); - - fs.writeFileSync(filePath, "foo", "utf8"); - - // chokidar emitted a change, - // meaning it watched the file correctly - server.staticWatchers[0].on("change", () => { - fs.unlinkSync(filePath); - - done(); - }); - - // change a file manually - setTimeout(() => { - fs.writeFileSync(filePath, "bar", "utf8"); - }, 1000); - }); - }); - - describe("test listing files in folders without index.html using the option static.serveIndex: false", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - watch: true, - serveIndex: false - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should not list the files inside the assets folder (404)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/assets`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should show Heyo. because bar has index.html inside it (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/bar`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("test listing files in folders without index.html using the option static.serveIndex: true", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - watch: true, - serveIndex: true - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should list the files inside the assets folder (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/assets/`, { - waitUntil: "networkidle0" - }); - - const text = await response.text(); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(text).toContain("example.txt"); - expect(text).toContain("other.txt"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should show Heyo. because bar has index.html inside it (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/bar/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("test listing files in folders without index.html using the default static.serveIndex option (true)", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - watch: true - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should list the files inside the assets folder (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/assets`, { - waitUntil: "networkidle0" - }); - - const text = await response.text(); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(text).toContain("example.txt"); - expect(text).toContain("other.txt"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should show Heyo. because bar has index.html inside it (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/bar`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("to multiple directories", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: [publicDirectory, otherPublicDirectory], - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle request first directory", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to second directory", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/foo.html`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("testing single & multiple external paths", () => { - let server; - - afterEach(done => { - testServer.close(() => { - done(); - }); - }); - - it("Should throw exception (external url)", done => { - expect.assertions(1); - - server = testServer.start( - config, - { - static: "https://example.com/" - }, - error => { - expect(error.message).toBe( - "Using a URL as static.directory is not supported" - ); - - server.stopCallback(done); - } - ); - }); - - it("Should not throw exception (local path with lower case first character)", done => { - testServer.start( - config, - { - static: { - directory: - publicDirectory.charAt(0).toLowerCase() + - publicDirectory.substring(1), - watch: true - }, - port - }, - done - ); - }); - - it("Should not throw exception (local path with lower case first character & has '-')", done => { - testServer.start( - config, - { - static: { - directory: "c:\\absolute\\path\\to\\content-base", - watch: true - }, - port - }, - done - ); - }); - - it("Should not throw exception (local path with upper case first character & has '-')", done => { - testServer.start( - config, - { - static: { - directory: "C:\\absolute\\path\\to\\content-base", - watch: true - }, - port - }, - done - ); - }); - - it("Should throw exception (array with absolute url)", done => { - server = testServer.start( - config, - { - static: [publicDirectory, "https://example.com/"] - }, - error => { - expect(error.message).toBe( - "Using a URL as static.directory is not supported" - ); - - server.stopCallback(done); - } - ); - }); - }); - - describe("defaults to PWD", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - jest - .spyOn(process, "cwd") - .mockImplementation(() => path.resolve(staticDirectory)); - compiler = webpack(config); - - server = new Server( - { - // eslint-disable-next-line no-undefined - static: undefined, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle request to /index.html", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/index.html`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("disabled", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - // This is a somewhat weird test, but it is important that we mock - // the PWD here, and test if /other.html in our "fake" PWD really is not requested. - jest.spyOn(process, "cwd").mockImplementation(() => publicDirectory); - - compiler = webpack(config); - - server = new Server( - { - static: false, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should not handle request to /other.html (404)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/index.html`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/static-public-path.test.js b/packages/rspack-dev-server/tests/e2e/static-public-path.test.js deleted file mode 100644 index 38e27f50120..00000000000 --- a/packages/rspack-dev-server/tests/e2e/static-public-path.test.js +++ /dev/null @@ -1,1101 +0,0 @@ -"use strict"; - -const path = require("path"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/static-config/webpack.config"); -const port = require("../helpers/ports-map")["static-public-path-option"]; -const runBrowser = require("../helpers/run-browser"); - -const staticDirectory = path.resolve(__dirname, "../fixtures/static-config"); -const publicDirectory = path.resolve(staticDirectory, "public"); -const otherPublicDirectory = path.resolve(staticDirectory, "other"); -const staticPublicPath = "/serve-content-at-this-url"; -const otherStaticPublicPath = "/serve-other-content-at-this-url"; - -describe("static.publicPath option", () => { - describe("to directory", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - publicPath: staticPublicPath, - watch: true - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle request to index", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to other file", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/other.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("test listing files in folders without index.html using the option static.serveIndex: false", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - publicPath: staticPublicPath, - watch: true, - serveIndex: false - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("shouldn't list the files inside the assets folder (404)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should show Heyo. because bar has index.html inside it (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/bar`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("test listing files in folders without index.html using the option static.serveIndex: true", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - publicPath: staticPublicPath, - watch: true, - serveIndex: true - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should list the files inside the assets folder (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toContain("other.txt"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should show Heyo. because bar has index.html inside it (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/bar`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("test listing files in folders without index.html using the option static.serveIndex default (true)", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - publicPath: staticPublicPath, - watch: true, - serveIndex: true - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should list the files inside the assets folder (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toContain("other.txt"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should show Heyo. because bar has index.html inside it (200)", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/bar`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("to multiple directories", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: [ - { - directory: publicDirectory, - publicPath: staticPublicPath - }, - { - directory: otherPublicDirectory, - publicPath: staticPublicPath - } - ], - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle request to first directory", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to second directory", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/foo.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("defaults to CWD", () => { - let cwdSpy; - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - cwdSpy = jest - .spyOn(process, "cwd") - .mockImplementation(() => staticDirectory); - - compiler = webpack(config); - - server = new Server( - { - static: { - publicPath: staticPublicPath - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - cwdSpy.mockRestore(); - - await browser.close(); - await server.stop(); - }); - - it("should handle request to page", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/index.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("Content type", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - publicPath: staticPublicPath - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle request to example.txt", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/assets/example.txt`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(response.headers()["content-type"]).toMatchSnapshot( - "response header content-type" - ); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("should ignore methods other than GET and HEAD", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: { - directory: publicDirectory, - publicPath: staticPublicPath - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle GET request", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle HEAD request", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - - interceptedRequest.continue({ method: "HEAD" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should not handle POST request", async () => { - await page.setRequestInterception(true); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - interceptedRequest.continue({ method: "POST" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should not handle PUT request", async () => { - await page.setRequestInterception(true); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - interceptedRequest.continue({ method: "PUT" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should not handle DELETE request", async () => { - await page.setRequestInterception(true); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - interceptedRequest.continue({ method: "DELETE" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should not handle PATCH request", async () => { - await page.setRequestInterception(true); - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }) - .on("request", interceptedRequest => { - interceptedRequest.continue({ method: "PATCH" }); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("multiple static.publicPath entries", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: [ - { - directory: publicDirectory, - publicPath: staticPublicPath, - watch: true - }, - { - directory: otherPublicDirectory, - publicPath: otherStaticPublicPath, - watch: true - } - ], - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle request to the index of first path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to the other file of first path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/other.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to the /foo route of second path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${otherStaticPublicPath}/foo.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); - - describe("multiple static.publicPath entries with publicPath array", () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - static: [ - { - directory: publicDirectory, - publicPath: staticPublicPath, - watch: true - }, - { - directory: otherPublicDirectory, - publicPath: [staticPublicPath, otherStaticPublicPath], - watch: true - } - ], - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should handle request to the index of first path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to the other file of first path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/other.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to the /foo route of first path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${staticPublicPath}/foo.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - - it("should handle request to the /foo route of second path", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto( - `http://127.0.0.1:${port}${otherStaticPublicPath}/foo.html`, - { - waitUntil: "networkidle0" - } - ); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(await response.text()).toMatchSnapshot("response text"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/stats.test.js b/packages/rspack-dev-server/tests/e2e/stats.test.js deleted file mode 100644 index 2ce82602469..00000000000 --- a/packages/rspack-dev-server/tests/e2e/stats.test.js +++ /dev/null @@ -1,147 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const HTMLGeneratorPlugin = require("../helpers/html-generator-plugin"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").stats; - -global.console.log = jest.fn(); - -describe("stats", () => { - const cases = [ - { - title: 'should work when "stats" is not specified', - webpackOptions: {} - }, - { - title: 'should work using "{}" value for the "stats" option', - webpackOptions: { - stats: {} - } - }, - { - title: 'should work using "undefined" value for the "stats" option', - webpackOptions: { - // eslint-disable-next-line no-undefined - stats: undefined - } - }, - { - title: 'should work using "false" value for the "stats" option', - webpackOptions: { - stats: false - } - }, - { - title: 'should work using "errors-only" value for the "stats" option', - webpackOptions: { - stats: "errors-only" - } - }, - { - title: - 'should work using "{ assets: false }" value for the "stats" option', - webpackOptions: { - stats: { - assets: false - } - } - } - // TODO: support object `config.stats.colors` - // { - // title: - // 'should work using "{ assets: false }" value for the "stats" option', - // webpackOptions: { - // stats: { - // colors: { - // green: "\u001b[32m", - // }, - // }, - // }, - // }, - // `config.stats.warningsFilter` is deprecated in favor of config.ignoreWarnings - // { - // title: - // 'should work using "{ warningsFilter: \'test\' }" value for the "stats" option', - // webpackOptions: { - // plugins: [ - // { - // apply(compiler) { - // compiler.hooks.thisCompilation.tap( - // "warnings-webpack-plugin", - // (compilation) => { - // compilation.warnings.push( - // new Error("Warning from compilation"), - // ); - // }, - // ); - // }, - // }, - // new HTMLGeneratorPlugin(), - // ], - // stats: { warningsFilter: /Warning from compilation/ }, - // }, - // }, - ]; - - if (webpack.version.startsWith("5")) { - cases.push({ - title: 'should work and respect the "ignoreWarnings" option', - webpackOptions: { - plugins: [ - { - apply(compiler) { - compiler.hooks.thisCompilation.tap( - "warnings-webpack-plugin", - compilation => { - compilation.warnings.push( - new Error("Warning from compilation") - ); - } - ); - } - }, - new HTMLGeneratorPlugin() - ], - ignoreWarnings: [/Warning from compilation/] - } - }); - } - - cases.forEach(testCase => { - it(testCase.title, async () => { - const compiler = webpack({ ...config, ...testCase.webpackOptions }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const consoleMessages = []; - - page.on("console", message => { - consoleMessages.push(message); - }); - - await page.goto(`http://localhost:${port}/`, { - waitUntil: "networkidle0" - }); - - expect( - consoleMessages.map(message => message.text()) - ).toMatchSnapshot(); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/target.test.js b/packages/rspack-dev-server/tests/e2e/target.test.js deleted file mode 100644 index 0bc47381f08..00000000000 --- a/packages/rspack-dev-server/tests/e2e/target.test.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map").target; - -describe("target", () => { - const targets = [ - false, - "browserslist:defaults", - "web", - "webworker", - "node", - "async-node", - "electron-main", - "electron-preload", - "electron-renderer", - "nwjs", - "node-webkit", - "es5", - ["web", "es5"] - ]; - - for (const target of targets) { - it(`should work using "${target}" target`, async () => { - const compiler = webpack({ - ...config, - target, - ...(target === false || target === "es5" - ? { - output: { chunkFormat: "array-push", path: "/" } - } - : {}) - }); - const devServerOptions = { - port - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - // TODO: check why require is defined in theses target - // if ( - // target === "node" || - // target === "async-node" || - // target === "electron-main" || - // target === "electron-preload" || - // target === "electron-renderer" || - // target === "nwjs" || - // target === "node-webkit" - // ) { - // console.log(pageErrors); - // const hasRequireOrGlobalError = - // pageErrors.filter((pageError) => - // /require is not defined|global is not defined/.test(pageError), - // ).length === 1; - - // expect(hasRequireOrGlobalError).toBe(true); - // } else { - // expect(pageErrors).toMatchSnapshot("page errors"); - // } - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - } -}); diff --git a/packages/rspack-dev-server/tests/e2e/watch-files.test.js b/packages/rspack-dev-server/tests/e2e/watch-files.test.js deleted file mode 100644 index 0e77d84d399..00000000000 --- a/packages/rspack-dev-server/tests/e2e/watch-files.test.js +++ /dev/null @@ -1,682 +0,0 @@ -"use strict"; - -const path = require("path"); -const chokidar = require("chokidar"); -const fs = require("graceful-fs"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/watch-files-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["watch-files-option"]; - -const watchDir = path.resolve( - __dirname, - "../fixtures/watch-files-config/public" -); - -describe("watchFiles option", () => { - describe("should work with string and path to file", () => { - const file = path.join(watchDir, "assets/example.txt"); - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - watchFiles: file, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - fs.truncateSync(file); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - // change file content - fs.writeFileSync(file, "Kurosaki Ichigo", "utf8"); - - await new Promise(resolve => { - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(file); - - resolve(); - }); - }); - }); - }); - - describe("should work with string and path to directory", () => { - const file = path.join(watchDir, "assets/example.txt"); - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - watchFiles: watchDir, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - fs.truncateSync(file); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - // change file content - fs.writeFileSync(file, "Kurosaki Ichigo", "utf8"); - - await new Promise(resolve => { - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(file); - - resolve(); - }); - }); - }); - }); - - describe("should work with string and glob", () => { - const file = path.join(watchDir, "assets/example.txt"); - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - watchFiles: `${watchDir}/**/*`, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - fs.truncateSync(file); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - // change file content - fs.writeFileSync(file, "Kurosaki Ichigo", "utf8"); - - await new Promise(resolve => { - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(file); - - resolve(); - }); - }); - }); - }); - - describe("should not crash if file doesn't exist", () => { - const nonExistFile = path.join(watchDir, "assets/non-exist.txt"); - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - try { - fs.unlinkSync(nonExistFile); - } catch (error) { - // ignore - } - - compiler = webpack(config); - - server = new Server( - { - watchFiles: nonExistFile, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - await new Promise(resolve => { - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(nonExistFile); - resolve(); - }); - - // create file content - setTimeout(() => { - fs.writeFileSync(nonExistFile, "Kurosaki Ichigo", "utf8"); - // change file content - setTimeout(() => { - fs.writeFileSync(nonExistFile, "Kurosaki Ichigo", "utf8"); - }, 1000); - }, 1000); - }); - }); - }); - - describe("should work with object with single path", () => { - const file = path.join(watchDir, "assets/example.txt"); - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - watchFiles: { paths: file }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - fs.truncateSync(file); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - // change file content - fs.writeFileSync(file, "Kurosaki Ichigo", "utf8"); - - await new Promise(resolve => { - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(file); - - resolve(); - }); - }); - }); - }); - - describe("should work with object with multiple paths", () => { - const file = path.join(watchDir, "assets/example.txt"); - const other = path.join(watchDir, "assets/other.txt"); - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - watchFiles: { paths: [file, other] }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - fs.truncateSync(file); - fs.truncateSync(other); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - // change file content - fs.writeFileSync(file, "foo", "utf8"); - fs.writeFileSync(other, "bar", "utf8"); - - await new Promise(resolve => { - const expected = [file, other]; - let changed = 0; - - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(expected.includes(changedPath)).toBeTruthy(); - - changed += 1; - - if (changed === 2) { - resolve(); - } - }); - }); - }); - }); - - describe("should work with array config", () => { - const file = path.join(watchDir, "assets/example.txt"); - const other = path.join(watchDir, "assets/other.txt"); - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - compiler = webpack(config); - - server = new Server( - { - watchFiles: [{ paths: [file] }, other], - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await browser.close(); - await server.stop(); - fs.truncateSync(file); - fs.truncateSync(other); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(response.status()).toMatchSnapshot("response status"); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - - expect(pageErrors).toMatchSnapshot("page errors"); - - // change file content - fs.writeFileSync(file, "foo", "utf8"); - fs.writeFileSync(other, "bar", "utf8"); - - await new Promise(resolve => { - let changed = 0; - - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(file); - - changed += 1; - - if (changed === 2) { - resolve(); - } - }); - server.staticWatchers[1].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(other); - - changed += 1; - - if (changed === 2) { - resolve(); - } - }); - }); - }); - }); - - describe("should work with options", () => { - const file = path.join(watchDir, "assets/example.txt"); - - const chokidarMock = jest.spyOn(chokidar, "watch"); - - const optionCases = [ - { - poll: true - }, - { - poll: 200 - }, - { - usePolling: true - }, - { - usePolling: true, - poll: 200 - }, - { - usePolling: false - }, - { - usePolling: false, - poll: 200 - }, - { - usePolling: false, - poll: true - }, - { - interval: 400, - poll: 200 - }, - { - usePolling: true, - interval: 200, - poll: 400 - }, - { - usePolling: false, - interval: 200, - poll: 400 - } - ]; - - optionCases.forEach(optionCase => { - describe(JSON.stringify(optionCase), () => { - let compiler; - let server; - let page; - let browser; - let pageErrors; - let consoleMessages; - - beforeEach(async () => { - chokidarMock.mockClear(); - - compiler = webpack(config); - - server = new Server( - { - watchFiles: { - paths: file, - options: optionCase - }, - port - }, - compiler - ); - - await server.start(); - - ({ page, browser } = await runBrowser()); - - pageErrors = []; - consoleMessages = []; - }); - - afterEach(async () => { - await server.stop(); - await browser.close(); - fs.truncateSync(file); - }); - - it("should reload when file content is changed", async () => { - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const response = await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - // should pass correct options to chokidar config - expect(chokidarMock.mock.calls[0][1]).toMatchSnapshot(); - - expect(response.status()).toMatchSnapshot("response status"); - - expect( - consoleMessages.map(message => message.text()) - ).toMatchSnapshot("console messages"); - - expect(pageErrors).toMatchSnapshot("page errors"); - - // change file content - fs.writeFileSync(file, "Kurosaki Ichigo", "utf8"); - - await new Promise(resolve => { - server.staticWatchers[0].on("change", async changedPath => { - // page reload - await page.waitForNavigation({ waitUntil: "networkidle0" }); - - expect(changedPath).toBe(file); - - resolve(); - }); - }); - }); - }); - }); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/web-socket-communication.test.js b/packages/rspack-dev-server/tests/e2e/web-socket-communication.test.js deleted file mode 100644 index e78eafa2317..00000000000 --- a/packages/rspack-dev-server/tests/e2e/web-socket-communication.test.js +++ /dev/null @@ -1,223 +0,0 @@ -"use strict"; - -const WebSocket = require("ws"); -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const WebsocketServer = require("webpack-dev-server/lib/servers/WebsocketServer"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const port = require("../helpers/ports-map")["web-socket-communication"]; - -jest.setTimeout(60000); - -describe("web socket communication", () => { - const webSocketServers = ["ws", "sockjs"]; - - webSocketServers.forEach(websocketServer => { - it(`should work and close web socket client connection when web socket server closed ("${websocketServer}")`, async () => { - WebsocketServer.heartbeatInterval = 100; - - const compiler = webpack(config); - const devServerOptions = { - port, - webSocketServer: websocketServer - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message.text()); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - await server.stop(); - await new Promise(resolve => { - const interval = setInterval(() => { - if ( - consoleMessages.includes("[webpack-dev-server] Disconnected!") - ) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); - - expect(consoleMessages).toMatchSnapshot("console messages"); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - } - }); - - it(`should work and terminate client that is not alive ("${websocketServer}")`, async () => { - WebsocketServer.heartbeatInterval = 100; - - const compiler = webpack(config); - const devServerOptions = { - port, - webSocketServer: websocketServer - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - await browser.close(); - - // Wait heartbeat - await new Promise(resolve => { - setTimeout(() => { - resolve(); - }, 200); - }); - - expect(server.webSocketServer.clients.length).toBe(0); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await server.stop(); - } - }); - - it(`should work and reconnect when the connection is lost ("${websocketServer}")`, async () => { - WebsocketServer.heartbeatInterval = 100; - - const compiler = webpack(config); - const devServerOptions = { - port, - webSocketServer: websocketServer - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - await server.stop(); - await server.start(); - - await page.waitForNavigation({ - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - }); - - it(`should work and do heartbeat using ("ws" web socket server)`, async () => { - WebsocketServer.heartbeatInterval = 100; - - const compiler = webpack(config); - const devServerOptions = { - port, - webSocketServer: "ws" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - server.webSocketServer.heartbeatInterval = 100; - - await new Promise((resolve, reject) => { - const ws = new WebSocket(`ws://127.0.0.1:${devServerOptions.port}/ws`, { - headers: { - host: `127.0.0.1:${devServerOptions.port}`, - origin: `http://127.0.0.1:${devServerOptions.port}` - } - }); - - let opened = false; - let received = false; - - ws.on("open", () => { - opened = true; - }); - - ws.on("error", error => { - reject(error); - }); - - ws.on("ping", () => { - if (opened && received) { - ws.close(); - } - }); - - ws.on("message", data => { - const message = JSON.parse(data); - - if (message.type === "ok") { - received = true; - } - }); - - ws.on("close", () => { - resolve(); - }); - }); - - await server.stop(); - }); -}); diff --git a/packages/rspack-dev-server/tests/e2e/web-socket-server-url.test.js b/packages/rspack-dev-server/tests/e2e/web-socket-server-url.test.js deleted file mode 100644 index c537b381a8f..00000000000 --- a/packages/rspack-dev-server/tests/e2e/web-socket-server-url.test.js +++ /dev/null @@ -1,2766 +0,0 @@ -"use strict"; - -const express = require("express"); -const webpack = require("@rspack/core"); -const { createProxyMiddleware } = require("http-proxy-middleware"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const sessionSubscribe = require("../helpers/session-subscribe"); -const [port1, port2] = require("../helpers/ports-map")["web-socket-server-url"]; - -const webSocketServers = ["ws", "sockjs"]; - -describe("web socket server URL", () => { - for (const webSocketServer of webSocketServers) { - const websocketURLProtocol = webSocketServer === "ws" ? "ws" : "http"; - - it(`should work behind proxy, when hostnames are same and ports are different ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = devServerHost; - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - app.use( - "/", - createProxyMiddleware({ - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${devServerHost}:${devServerPort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - await browser.close(); - await server.stop(); - } - }); - - it(`should work behind proxy, when hostnames are different and ports are same ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = Server.internalIPSync("v4"); - const proxyPort = port1; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - app.use( - "/", - createProxyMiddleware({ - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${devServerHost}:${devServerPort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - await browser.close(); - await server.stop(); - } - }); - - it(`should work behind proxy, when hostnames are different and ports are different ("${webSocketServer}")`, async () => { - const devServerHost = "127.0.0.1"; - const devServerPort = port1; - const proxyHost = Server.internalIPSync("v4"); - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - hostname: devServerHost - } - }, - webSocketServer, - port: devServerPort, - host: devServerHost, - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - function startProxy(callback) { - const app = express(); - app.use( - "/", - createProxyMiddleware({ - target: `http://${devServerHost}:${devServerPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${devServerHost}:${devServerPort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - } - }); - - it(`should work behind proxy, when the "host" option is "local-ip" and the "port" option is "auto" ("${webSocketServer}")`, async () => { - process.env.WEBPACK_DEV_SERVER_BASE_PORT = 40000; - - const proxyHost = Server.internalIPSync("v4"); - const proxyPort = port2; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: "auto", - host: "local-ip", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const resolvedHost = server.options.host; - const resolvedPort = server.options.port; - - function startProxy(callback) { - const app = express(); - - app.use( - "/", - createProxyMiddleware({ - target: `http://${resolvedHost}:${resolvedPort}`, - ws: true, - changeOrigin: true, - logLevel: "warn" - }) - ); - - return app.listen(proxyPort, proxyHost, callback); - } - - const proxy = await new Promise(resolve => { - const proxyCreated = startProxy(() => { - resolve(proxyCreated); - }); - }); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://${proxyHost}:${proxyPort}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${resolvedHost}:${resolvedPort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - proxy.close(); - - await browser.close(); - await server.stop(); - - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - } - }); - - it(`should work with the "client.webSocketURL.protocol" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - protocol: "ws:" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://localhost:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://localhost:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.protocol" option using "auto:" value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - protocol: "auto:" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://localhost:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://localhost:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.protocol" option using "http:" value and covert to "ws:" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - protocol: "http:" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://localhost:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://localhost:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.host" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - hostname: "127.0.0.1" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.host" option using "0.0.0.0" value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - hostname: "0.0.0.0" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.port" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: port1 - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.port" option as string ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: `${port1}` - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with "client.webSocketURL.port" and "webSocketServer.options.port" options as string ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - webSocketServer: { - type: webSocketServer, - options: { - host: "0.0.0.0", - // "sockjs" doesn't support external server - port: webSocketServer === "sockjs" ? `${port1}` : `${port2}` - } - }, - port: port1, - host: "0.0.0.0", - client: { - webSocketURL: { - port: webSocketServer === "sockjs" ? `${port1}` : `${port2}` - } - }, - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - webSocketServer === "sockjs" - ? `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - : `${websocketURLProtocol}://127.0.0.1:${port2}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.port" option using "0" value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - port: 0 - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.pathname" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - pathname: "/ws" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with default "/ws" value of the "client.webSocketURL.pathname" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.username" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - username: "zenitsu" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://zenitsu@127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.password" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: - webSocketServer === "ws" - ? { - username: "foo", - password: "chuntaro" - } - : {} - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - // "sockjs" has bug with parsing URL - webSocketServer === "ws" - ? `${websocketURLProtocol}://foo:chuntaro@127.0.0.1:${port1}/ws` - : `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.username" and "client.webSocketURL.password" option ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - username: "zenitsu", - password: "chuntaro" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://zenitsu:chuntaro@127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the custom web socket server "path" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - webSocketServer: { - type: webSocketServer, - options: { - path: "/custom-ws/foo/bar" - } - }, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/custom-ws\/foo\/bar/.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/custom-ws/foo/bar` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - // Only works for "ws" server - it(`should work with the custom web socket server "path" using empty value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - webSocketServer: { - type: webSocketServer, - options: { - path: webSocketServer === "ws" ? "" : "/custom-ws" - } - }, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/custom-ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - webSocketServer === "ws" - ? `${websocketURLProtocol}://127.0.0.1:${port1}` - : `${websocketURLProtocol}://127.0.0.1:${port1}/custom-ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - pathname: "/custom-ws/foo/bar" - } - }, - webSocketServer: { - type: webSocketServer, - options: { - path: "/custom-ws/foo/bar" - } - }, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/custom-ws\/foo\/bar/.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/custom-ws/foo/bar` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending without slash ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - pathname: "/custom-ws" - } - }, - webSocketServer: { - type: webSocketServer, - options: { - path: "/custom-ws" - } - }, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/custom-ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/custom-ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - // Only works for "ws" server, "sockjs" adds "/" be default, because need do requests like "/custom-ws/info?t=1624462615772" - it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" ending with slash ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - pathname: webSocketServer === "ws" ? "/custom-ws/" : "/custom-ws" - } - }, - webSocketServer: { - type: webSocketServer, - options: { - path: webSocketServer === "ws" ? "/custom-ws/" : "/custom-ws" - } - }, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/custom-ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/custom-ws/` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - // Only works for "ws" server - it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "path" using empty value ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - pathname: webSocketServer === "ws" ? "" : "/custom-ws" - } - }, - webSocketServer: { - type: webSocketServer, - options: { - path: webSocketServer === "ws" ? "" : "/custom-ws" - } - }, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/custom-ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - webSocketServer === "ws" - ? `${websocketURLProtocol}://127.0.0.1:${port1}` - : `${websocketURLProtocol}://127.0.0.1:${port1}/custom-ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - // Only works for "sockjs" server - it(`should work with the "client.webSocketURL.pathname" option and the custom web socket server "prefix" for compatibility with "sockjs" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - pathname: "/custom-ws" - } - }, - webSocketServer: { - type: webSocketServer, - options: - webSocketServer === "ws" - ? { path: "/custom-ws" } - : { prefix: "/custom-ws" } - }, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/custom-ws/.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/custom-ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work when "host" option is IPv4 ("${webSocketServer}")`, async () => { - const hostname = Server.internalIPSync("v4"); - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: port1, - host: hostname - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://${hostname}:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${hostname}:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work when "host" option is "local-ip" ("${webSocketServer}")`, async () => { - const hostname = Server.internalIPSync("v4"); - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: port1, - host: "local-ip" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://${hostname}:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${hostname}:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work when "host" option is "local-ipv4" ("${webSocketServer}")`, async () => { - const hostname = Server.internalIPSync("v4"); - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: port1, - host: "local-ipv4" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - await page.goto(`http://${hostname}:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://${hostname}:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with "server: 'https'" option ("${webSocketServer}")`, async () => { - const hostname = "127.0.0.1"; - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: port1, - server: "https" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`https://${hostname}:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - if (webSocketServer === "ws") { - expect(webSocketRequest.url).toContain( - `wss://${hostname}:${port1}/ws` - ); - } else { - expect(webSocketRequest.url).toContain( - `https://${hostname}:${port1}/ws` - ); - } - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with "server: 'spdy'" option ("${webSocketServer}")`, async () => { - const hostname = "127.0.0.1"; - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: port1, - server: "spdy" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`https://${hostname}:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - if (webSocketServer === "ws") { - expect(webSocketRequest.url).toContain( - `wss://${hostname}:${port1}/ws` - ); - } else { - expect(webSocketRequest.url).toContain( - `https://${hostname}:${port1}/ws` - ); - } - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work when "port" option is "auto" ("${webSocketServer}")`, async () => { - process.env.WEBPACK_DEV_SERVER_BASE_PORT = 50000; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer, - port: "auto", - host: "0.0.0.0" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const resolvedFreePort = server.options.port; - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${resolvedFreePort}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${resolvedFreePort}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - - delete process.env.WEBPACK_DEV_SERVER_BASE_PORT; - } - }); - - it(`should work with "client.webSocketURL.*" options ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: { - protocol: "ws:", - hostname: "127.0.0.1", - port: port1, - pathname: "/ws" - } - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work with the "client.webSocketURL" option as "string" ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: `ws://127.0.0.1:${port1}/ws` - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - - if (webSocketServer === "ws") { - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - } else { - page.on("request", request => { - if (/\/ws\//.test(request.url())) { - webSocketRequests.push({ url: request.url() }); - } - }); - } - - await page.goto(`http://127.0.0.1:${port1}/`, { - waitUntil: "networkidle0" - }); - - const webSocketRequest = webSocketRequests[0]; - - expect(webSocketRequest.url).toContain( - `${websocketURLProtocol}://127.0.0.1:${port1}/ws` - ); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should work and throw an error on invalid web socket URL ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: "unknown://unknown.unknown/unknown" - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://localhost:${port1}/`, { - waitUntil: "networkidle0" - }); - - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect( - pageErrors.map(pageError => pageError.message.split("\n")[0]) - ).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - - it(`should not work and output disconnect wrong web socket URL ("${webSocketServer}")`, async () => { - const compiler = webpack(config); - const devServerOptions = { - client: { - webSocketURL: "ws://unknown.unknown/unknown" - }, - webSocketServer, - port: port1, - host: "0.0.0.0", - allowedHosts: "all" - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - let isDisconnected = false; - - page - .on("console", message => { - const text = message.text(); - - if (!isDisconnected) { - isDisconnected = /Disconnected!/.test(text); - consoleMessages.push(text.replace(/:[\d]+/g, ":")); - } - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - await page.goto(`http://localhost:${port1}/`, { - waitUntil: "networkidle0" - }); - - await new Promise(resolve => { - const interval = setInterval(() => { - if ( - consoleMessages.includes("[webpack-dev-server] Disconnected!") - ) { - clearInterval(interval); - - resolve(); - } - }, 100); - }); - - // TODO: not stable on lynx linux ci - // expect(consoleMessages).toMatchSnapshot("console messages"); - expect( - pageErrors.map(pageError => pageError.message.split("\n")[0]) - ).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); - } -}); diff --git a/packages/rspack-dev-server/tests/e2e/web-socket-server.test.js b/packages/rspack-dev-server/tests/e2e/web-socket-server.test.js deleted file mode 100644 index 44ba6ac53f8..00000000000 --- a/packages/rspack-dev-server/tests/e2e/web-socket-server.test.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; - -const webpack = require("@rspack/core"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); -const config = require("../fixtures/client-config/webpack.config"); -const runBrowser = require("../helpers/run-browser"); -const sessionSubscribe = require("../helpers/session-subscribe"); -const port = require("../helpers/ports-map")["web-socket-server-test"]; - -describe("web socket server", () => { - it("should work allow to disable", async () => { - const devServerPort = port; - - const compiler = webpack(config); - const devServerOptions = { - webSocketServer: false, - port: devServerPort - }; - const server = new Server(devServerOptions, compiler); - - await server.start(); - - const { page, browser } = await runBrowser(); - - try { - const pageErrors = []; - const consoleMessages = []; - - page - .on("console", message => { - consoleMessages.push(message); - }) - .on("pageerror", error => { - pageErrors.push(error); - }); - - const webSocketRequests = []; - const session = await page.target().createCDPSession(); - - session.on("Network.webSocketCreated", test => { - webSocketRequests.push(test); - }); - - await session.send("Target.setAutoAttach", { - autoAttach: true, - flatten: true, - waitForDebuggerOnStart: true - }); - - sessionSubscribe(session); - - await page.goto(`http://127.0.0.1:${port}/`, { - waitUntil: "networkidle0" - }); - - expect(webSocketRequests).toHaveLength(0); - expect(consoleMessages.map(message => message.text())).toMatchSnapshot( - "console messages" - ); - expect(pageErrors).toMatchSnapshot("page errors"); - } catch (error) { - throw error; - } finally { - await browser.close(); - await server.stop(); - } - }); -}); diff --git a/packages/rspack-dev-server/tests/fixtures/client-config/bar.js b/packages/rspack-dev-server/tests/fixtures/client-config/bar.js deleted file mode 100644 index 1ae523febc6..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/client-config/bar.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Bar."); diff --git a/packages/rspack-dev-server/tests/fixtures/client-config/foo.js b/packages/rspack-dev-server/tests/fixtures/client-config/foo.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/client-config/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/client-config/index.html b/packages/rspack-dev-server/tests/fixtures/client-config/index.html deleted file mode 100644 index 5b1eef45117..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/client-config/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packages/rspack-dev-server/tests/fixtures/client-config/static/foo.txt b/packages/rspack-dev-server/tests/fixtures/client-config/static/foo.txt deleted file mode 100644 index 4add785dafe..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/client-config/static/foo.txt +++ /dev/null @@ -1 +0,0 @@ -Text \ No newline at end of file diff --git a/packages/rspack-dev-server/tests/fixtures/client-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/client-config/webpack.config.js deleted file mode 100644 index 7bbb8522b31..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/client-config/webpack.config.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - devtool: false, - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/custom-client/CustomSockJSClient.js b/packages/rspack-dev-server/tests/fixtures/custom-client/CustomSockJSClient.js deleted file mode 100644 index 038eaa15d9c..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/custom-client/CustomSockJSClient.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copy from webpack-dev-server - */ - -"use strict"; - -const SockJS = require("sockjs-client/dist/sockjs"); - -module.exports = class SockJSClient { - constructor(url) { - this.sock = new SockJS( - url.replace(/^ws:/i, "http://").replace(/^wss:/i, "https://") - ); - } - - onOpen(f) { - this.sock.onopen = () => { - console.log("open"); - f(); - }; - } - - onClose(f) { - this.sock.onclose = () => { - console.log("close"); - f(); - }; - } - - // call f with the message string as the first argument - onMessage(f) { - this.sock.onmessage = e => { - const obj = JSON.parse(e.data); - console.log(obj.type); - f(e.data); - }; - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/bar.html b/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/bar.html deleted file mode 100644 index d0e33400779..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/bar.html +++ /dev/null @@ -1 +0,0 @@ -Foobar diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/foo.js b/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/foo.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/other.html b/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/other.html deleted file mode 100644 index d7334729422..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/other.html +++ /dev/null @@ -1 +0,0 @@ -Other file diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/random-file.txt b/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/random-file.txt deleted file mode 100644 index c7ab7e7ea3f..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/random-file.txt +++ /dev/null @@ -1 +0,0 @@ -Random file diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/webpack.config.js deleted file mode 100644 index 65cf2bfbc11..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-2-config/webpack.config.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/bar.html b/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/bar.html deleted file mode 100644 index 5dee24d5b36..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/bar.html +++ /dev/null @@ -1 +0,0 @@ -In-memory file diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/foo.js b/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/foo.js deleted file mode 100644 index aae7eee3a77..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/foo.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -require("./bar.html"); - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/index.html b/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/index.html deleted file mode 100644 index 8824844272e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/index.html +++ /dev/null @@ -1 +0,0 @@ -static file diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/webpack.config.js deleted file mode 100644 index 72825cb8099..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-3-config/webpack.config.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -const moduleRuleForHTML = { - test: /\.html$/, - type: "asset/resource", - generator: { - filename: "index.html" - } -}; - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - module: { - rules: [ - { - ...moduleRuleForHTML - } - ] - }, - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/bar.html b/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/bar.html deleted file mode 100644 index d0e33400779..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/bar.html +++ /dev/null @@ -1 +0,0 @@ -Foobar diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/foo.js b/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/foo.js deleted file mode 100644 index fa06808d305..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/foo.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; - -require("./index.html"); -require("./bar.html"); - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/index.html b/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/index.html deleted file mode 100644 index f4defc9b2b5..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/index.html +++ /dev/null @@ -1 +0,0 @@ -Heyyy diff --git a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/webpack.config.js deleted file mode 100644 index 25ab1d4f719..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/historyapifallback-config/webpack.config.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -const moduleRuleForHTML = { - test: /\.html$/, - type: "asset/resource", - generator: { - filename: "[name][ext]" - } -}; - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - module: { - rules: [ - { - ...moduleRuleForHTML - } - ] - }, - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/ca-symlink.pem b/packages/rspack-dev-server/tests/fixtures/https-certificate/ca-symlink.pem deleted file mode 120000 index e375f5ab0d5..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/https-certificate/ca-symlink.pem +++ /dev/null @@ -1 +0,0 @@ -ca.pem \ No newline at end of file diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/ca.pem b/packages/rspack-dev-server/tests/fixtures/https-certificate/ca.pem deleted file mode 100644 index 05b314535be..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/https-certificate/ca.pem +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv -C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu -Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs -EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw -duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+ -T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J -G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu -CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8 -oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ -tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc -pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k+s7c4c5X7XDm3X0GWeSbqBMJb8q7 -BhZQNzECgYEA4kAtymDBvFYiZFq7+lzQBRKAI1RCq7YqxlieumH0PSkie2bba3dW -NVdTi7at8+GDB9/cHUPKzg/skfJllek57MZmusiVwB/Lmp/IlW8YyGShdYZ7zQsV -KMWJljpky3BEDM5sb08wIkfrOkelI/S4Bqqabd9JzOMJzoTiVOlMam8CgYEA3ctN -yonWz2bsnCUstQvQCLdI5a8Q7GJvlH2awephxGXIKGUuRmyyop0AnRnIBEWtOQV7 -yZjW32bU+Wt+2BJ247EyJiIQ4gT+T51t+v/Wt1YNbL3dSj9ttOvwYd4H2W4E7EIO -GKIF4I39FM7r8NfG7YE7S1aVcnrqs01N3nhd9HMCgYEAjepbzpmqbAxLPk97oase -AFB+d6qetz5ozklAJwDSRprKukTmVR5hwMup5/UKX/OQURwl4WVojKCIb3NwLPxC -DTbVsUuoQv6uo6qeEr3A+dHFRQa6GP9eolhl2Ql/t+wPg0jn01oEgzxBXCkceNVD -qUrR2yE4FYBD4nqPzVsZR5kCgYEA1yTi7NkQeldIpZ6Z43T18753A/Xx4JsLyWqd -uAT3mV9x7V1Yqg++qGbLtZjQoPRFt85N6ZxMsqA5b0iK3mXq1auJDdx1rAlT9z6q -9JM/YNAkbZsvEVq9vIYxw31w98T1GYhpzBM+yDhzir+9tv5YhQKa1dXDWi1JhWwz -YN45pWkCgYEAxuVsJ4D4Th5o050ppWpnxM/WuMhIUKqaoFTVucMKFzn+g24y9pv5 -miYdNYIk4Y+4pzHG6ZGZSHJcQ9BLui6H/nLQnqkgCb2lT5nfp7/GKdus7BdcjPGs -fcV46yL7/X0m8nDb3hkwwrDTU4mKFkMrzKpjdZBsttEmW0Aw/3y36gU= ------END RSA PRIVATE KEY----- diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.crt b/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.crt deleted file mode 120000 index d23ad4d88e3..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.crt +++ /dev/null @@ -1 +0,0 @@ -server.crt \ No newline at end of file diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.key b/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.key deleted file mode 120000 index c26f438dd74..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.key +++ /dev/null @@ -1 +0,0 @@ -server.key \ No newline at end of file diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.pfx b/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.pfx deleted file mode 120000 index 89adfe8705f..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/https-certificate/server-symlink.pfx +++ /dev/null @@ -1 +0,0 @@ -server.pfx \ No newline at end of file diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/server.crt b/packages/rspack-dev-server/tests/fixtures/https-certificate/server.crt deleted file mode 100644 index 1992bb16104..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/https-certificate/server.crt +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDXTCCAkWgAwIBAgIJALz8gD/gAt0OMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTgxMDIzMTgyMTQ5WhcNMTkxMDIzMTgyMTQ5WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kvC/hf5Ei1 -J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYuDy9WkFuM -ie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhsEENnH6sU -E9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2swduxJTWRI -NmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+T8emgklS -tASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABo1AwTjAdBgNVHQ4EFgQUDZBhVKdb -3BRhLIhuuE522Vsul0IwHwYDVR0jBBgwFoAUDZBhVKdb3BRhLIhuuE522Vsul0Iw -DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEABh9WWZwWLgb9/DcTxL72 -6pI96t4jiF79Q+pPefkaIIi0mE6yodWrTAsBQu9I6bNRaEcCSoiXkP2bqskD/UGg -LwUFgSrDOAA3UjdHw3QU5g2NocduG7mcFwA40TB98sOsxsUyYlzSyWzoiQWwPYwb -hek1djuWkqPXsTjlj54PTPN/SjTFmo4p5Ip6nbRf2nOREl7v0rJpGbJvXiCMYyd+ -Zv+j4mRjCGo8ysMR2HjCUGkYReLAgKyyz3M7i8vevJhKslyOmy6Txn4F0nPVumaU -DDIy4xXPW1STWfsmSYJfYW3wa0wk+pJQ3j2cTzkPQQ8gwpvM3U9DJl43uwb37v6I -7Q== ------END CERTIFICATE----- diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/server.key b/packages/rspack-dev-server/tests/fixtures/https-certificate/server.key deleted file mode 100644 index c002d19e496..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/https-certificate/server.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDEBRUsUz4rdcMt -CQGLvG3SzUinsmgdgOyTNQNA0eOMyRSrmS8L+F/kSLUnqqu4mzdeqDzo2Xj553jK -dRqMCRFGJuGnQ/VIbW2A+ywgrqILuDyF5i4PL1aQW4yJ7TnXfONKfpswQArlN6DF -gBYJtoJlf8XD1sOeJpsv/O46/ix/wngQ+GwQQ2cfqxQT0fE9SBCY23VNt3SPUJ3k -9etJMvJ9U9GHSb1CFdNQe7Gyx7xdKf1TazB27ElNZEg2aF99if47uRskYjvvFivy -7nxGx/ccIwjwNMpk29AsKG++0sn1yTK7tD5Px6aCSVK0BKbdXZS2euJor8hASGBJ -3GpVGJvdAgMBAAECggEAapYo8TVCdPdP7ckb4hPP0/R0MVu9aW2VNmZ5ImH+zar5 -ZmWhQ20HF2bBupP/VB5yeTIaDLNUKO9Iqy4KBWNY1UCHKyC023FFPgFV+V98FctU -faqwGOmwtEZToRwxe48ZOISndhEc247oCPyg/x8SwIY9z0OUkwaDFBEAqWtUXxM3 -/SPpCT5ilLgxnRgVB8Fj5Z0q7ThnxNVOmVC1OSIakEj46PzmMXn1pCKLOCUmAAOQ -BnrOZuty2b8b2M/GHsktLZwojQQJmArnIBymTXQTVhaGgKSyOv1qvHLp9L1OJf0/ -Xm+/TqT6ztzhzlftcObdfQZZ5JuoEwlvyrsGFlA3MQKBgQDiQC3KYMG8ViJkWrv6 -XNAFEoAjVEKrtirGWJ66YfQ9KSJ7Zttrd1Y1V1OLtq3z4YMH39wdQ8rOD+yR8mWV -6Tnsxma6yJXAH8uan8iVbxjIZKF1hnvNCxUoxYmWOmTLcEQMzmxvTzAiR+s6R6Uj -9LgGqppt30nM4wnOhOJU6UxqbwKBgQDdy03KidbPZuycJSy1C9AIt0jlrxDsYm+U -fZrB6mHEZcgoZS5GbLKinQCdGcgERa05BXvJmNbfZtT5a37YEnbjsTImIhDiBP5P -nW36/9a3Vg1svd1KP2206/Bh3gfZbgTsQg4YogXgjf0Uzuvw18btgTtLVpVyeuqz -TU3eeF30cwKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV -HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY -/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX -JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3 -zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ -iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml -amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6 -Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW -QyvMqmN1kGy20SZbQDD/fLfqBQ== ------END PRIVATE KEY----- diff --git a/packages/rspack-dev-server/tests/fixtures/https-certificate/server.pfx b/packages/rspack-dev-server/tests/fixtures/https-certificate/server.pfx deleted file mode 100644 index e5ed9c79886..00000000000 Binary files a/packages/rspack-dev-server/tests/fixtures/https-certificate/server.pfx and /dev/null differ diff --git a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/one.js b/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/one.js deleted file mode 100644 index 3141da7ce02..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/one.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("One."); diff --git a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/two.js b/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/two.js deleted file mode 100644 index 0f719c90999..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/two.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Two."); diff --git a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/webpack.config.js deleted file mode 100644 index f3d3055f9fc..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-multiple-entries/webpack.config.js +++ /dev/null @@ -1,77 +0,0 @@ -"use strict"; - -const oneHTMLContent = ` - - - - - test - - - - -`; -const twoHTMLContent = ` - - - - - test - - - - -`; - -module.exports = { - devtool: false, - mode: "development", - context: __dirname, - stats: "none", - entry: { - one: "./one.js", - two: "./two.js" - }, - output: { - path: "/" - }, - experiments: { - lazyCompilation: true - }, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [ - { - apply(compiler) { - const pluginName = "html-generator-plugin-test"; - const oneFilename = "test-one.html"; - const twoFilename = "test-two.html"; - - compiler.hooks.thisCompilation.tap(pluginName, compilation => { - const { RawSource } = compiler.webpack.sources; - - compilation.hooks.processAssets.tap( - { - name: pluginName, - stage: - compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL - }, - () => { - const oneSource = new RawSource(oneHTMLContent); - - compilation.emitAsset(oneFilename, oneSource); - - const twoSource = new RawSource(twoHTMLContent); - - compilation.emitAsset(twoFilename, twoSource); - } - ); - }); - } - } - ] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-single-entry/entry.js b/packages/rspack-dev-server/tests/fixtures/lazy-compilation-single-entry/entry.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-single-entry/entry.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-single-entry/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/lazy-compilation-single-entry/webpack.config.js deleted file mode 100644 index bd5a5025fb1..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/lazy-compilation-single-entry/webpack.config.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; - -const HTMLContent = ` - - - - - test - - - - -`; - -module.exports = { - devtool: false, - mode: "development", - context: __dirname, - stats: "none", - entry: "./entry.js", - output: { - path: "/" - }, - experiments: { - lazyCompilation: true - }, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [ - { - apply(compiler) { - const pluginName = "html-generator-plugin-test"; - const filename = "test.html"; - - compiler.hooks.thisCompilation.tap(pluginName, compilation => { - const { RawSource } = compiler.webpack.sources; - - compilation.hooks.processAssets.tap( - { - name: pluginName, - stage: - compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL - }, - () => { - const source = new RawSource(HTMLContent); - - compilation.emitAsset(filename, source); - } - ); - }); - } - } - ] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/mime-types-config/file.custom b/packages/rspack-dev-server/tests/fixtures/mime-types-config/file.custom deleted file mode 100644 index 9daeafb9864..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/mime-types-config/file.custom +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/packages/rspack-dev-server/tests/fixtures/mime-types-config/foo.js b/packages/rspack-dev-server/tests/fixtures/mime-types-config/foo.js deleted file mode 100644 index 739d9bd6383..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/mime-types-config/foo.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -require("./file.custom"); - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/mime-types-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/mime-types-config/webpack.config.js deleted file mode 100644 index b96e4e6aec7..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/mime-types-config/webpack.config.js +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; - -const moduleRuleForCustom = { - test: /\.custom$/, - type: "asset/resource", - generator: { - filename: "[name][ext]" - } -}; - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "warn" - }, - module: { - rules: [ - { - ...moduleRuleForCustom - } - ] - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/module-federation-config/entry1.js b/packages/rspack-dev-server/tests/fixtures/module-federation-config/entry1.js deleted file mode 100644 index dbd0f49a83e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/module-federation-config/entry1.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -module.exports = "entry1"; diff --git a/packages/rspack-dev-server/tests/fixtures/module-federation-config/entry2.js b/packages/rspack-dev-server/tests/fixtures/module-federation-config/entry2.js deleted file mode 100644 index 74f9bc577fd..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/module-federation-config/entry2.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -module.exports = "entry2"; diff --git a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.config.js deleted file mode 100644 index d513196fbb5..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.config.js +++ /dev/null @@ -1,16 +0,0 @@ -"use strict"; - -module.exports = { - mode: "development", - target: "node", - stats: "none", - context: __dirname, - entry: ["./entry1.js", "./entry2.js"], - output: { - path: "/", - libraryTarget: "umd" - }, - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.multi.config.js b/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.multi.config.js deleted file mode 100644 index de92d76ab21..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.multi.config.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -module.exports = [ - { - mode: "development", - target: "node", - context: __dirname, - stats: "none", - entry: ["./entry1.js", "./entry2.js"], - output: { - path: "/", - libraryTarget: "umd" - }, - infrastructureLogging: { - level: "warn" - } - } -]; diff --git a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.object-entry.config.js b/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.object-entry.config.js deleted file mode 100644 index 7bbc9e8daa6..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.object-entry.config.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; - -module.exports = { - mode: "development", - target: "node", - stats: "none", - context: __dirname, - entry: { - foo: "./entry1.js", - main: ["./entry1.js", "./entry2.js"] - }, - output: { - path: "/", - libraryTarget: "umd" - }, - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.plugin.js b/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.plugin.js deleted file mode 100644 index f6ab0edfcae..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/module-federation-config/webpack.plugin.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -const ModuleFederationPlugin = - require("@rspack/core").container.ModuleFederationPlugin; - -module.exports = { - mode: "development", - target: "node", - stats: "none", - context: __dirname, - entry: ["./entry1.js"], - plugins: [ - new ModuleFederationPlugin({ - name: "app1", - library: { type: "var", name: "app1" }, - filename: "remoteEntry.js", - exposes: { - "./entry1": "./entry1" - } - }) - ], - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/multi-compiler-one-configuration/foo.js b/packages/rspack-dev-server/tests/fixtures/multi-compiler-one-configuration/foo.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-compiler-one-configuration/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/multi-compiler-one-configuration/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/multi-compiler-one-configuration/webpack.config.js deleted file mode 100644 index 11e40ee4d5d..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-compiler-one-configuration/webpack.config.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = [ - { - target: "web", - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] - } -]; diff --git a/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/one.js b/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/one.js deleted file mode 100644 index 21aaff9181a..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/one.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; - -console.log("one"); -// comment diff --git a/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/two.js b/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/two.js deleted file mode 100644 index 83bf26e4bb8..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/two.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("two"); diff --git a/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/webpack.config.js deleted file mode 100644 index 0d3aa41b8e8..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-compiler-two-configurations/webpack.config.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = [ - { - target: "web", - name: "one", - mode: "development", - context: __dirname, - entry: "./one.js", - stats: "none", - output: { - path: "/", - filename: "one-[name].js" - }, - plugins: [new HTMLGeneratorPlugin()], - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - } - }, - { - target: "web", - name: "two", - mode: "development", - context: __dirname, - entry: "./two.js", - stats: "none", - output: { - path: "/", - filename: "two-[name].js" - }, - plugins: [new HTMLGeneratorPlugin()], - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - } - } -]; diff --git a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/bar.js b/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/bar.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/bar.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/baz.js b/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/baz.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/baz.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/foo.js b/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/foo.js deleted file mode 100644 index d2f0aa53ddf..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -require("./test.html"); diff --git a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/test.html b/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/test.html deleted file mode 100644 index ce013625030..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/test.html +++ /dev/null @@ -1 +0,0 @@ -hello diff --git a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/webpack.config.js deleted file mode 100644 index d7ae8585cb4..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/multi-public-path-config/webpack.config.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; - -const path = require("path"); - -const moduleRuleForHTML = { - test: /\.html$/, - type: "asset/resource", - generator: { - filename: "path/to/file.html" - } -}; - -module.exports = [ - { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: __dirname, - filename: "foo.js", - publicPath: "/bundle1/" - }, - infrastructureLogging: { - level: "warn" - }, - module: { - rules: [ - { - ...moduleRuleForHTML - } - ] - } - }, - { - mode: "development", - context: __dirname, - stats: "none", - entry: "./bar.js", - output: { - path: path.join(__dirname, "named"), - filename: "bar.js", - publicPath: "/bundle2/" - }, - name: "named", - infrastructureLogging: { - level: "warn" - } - }, - { - mode: "development", - context: __dirname, - entry: "./bar.js", - output: { - path: path.join(__dirname, "dist"), - filename: "bar.js", - publicPath: "auto" - }, - name: "other", - stats: false - } -]; diff --git a/packages/rspack-dev-server/tests/fixtures/overlay-config/foo.js b/packages/rspack-dev-server/tests/fixtures/overlay-config/foo.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/fixtures/overlay-config/trusted-types.webpack.config.js b/packages/rspack-dev-server/tests/fixtures/overlay-config/trusted-types.webpack.config.js deleted file mode 100644 index 5cfa4ecfef2..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/overlay-config/trusted-types.webpack.config.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/trusted-types-html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/", - trustedTypes: { policyName: "webpack" } - }, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/overlay-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/overlay-config/webpack.config.js deleted file mode 100644 index 16bae608229..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/overlay-config/webpack.config.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-custom/foo.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-custom/foo.js deleted file mode 100644 index 12f6908db69..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-custom/foo.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; - -// 'npm run prepare' must be run for this to work during testing -const CustomClient = require("../custom-client/CustomSockJSClient"); - -window.expectedClient = CustomClient; -// eslint-disable-next-line camelcase, no-undef -window.injectedClient = __webpack_dev_server_client__; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-custom/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-custom/webpack.config.js deleted file mode 100644 index 3c235a726d8..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-custom/webpack.config.js +++ /dev/null @@ -1,26 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -/** - * @type {import('@rspack/core').RspackOptions} - */ -const config = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; - -module.exports = config; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-default/foo.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-default/foo.js deleted file mode 100644 index 538ae3e1b1f..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-default/foo.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -// 'npm run prepare' must be run for this to work during testing -const WebsocketClient = - require("webpack-dev-server/client/clients/WebSocketClient").default; - -window.expectedClient = WebsocketClient; -// eslint-disable-next-line camelcase, no-undef -window.injectedClient = __webpack_dev_server_client__.default; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-default/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-default/webpack.config.js deleted file mode 100644 index 661a14db435..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-default/webpack.config.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-sockjs-config/foo.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-sockjs-config/foo.js deleted file mode 100644 index 3b43d16ad13..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-sockjs-config/foo.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -// 'npm run prepare' must be run for this to work during testing -const SockJSClient = - require("webpack-dev-server/client/clients/SockJSClient").default; - -window.expectedClient = SockJSClient; -// eslint-disable-next-line camelcase, no-undef -window.injectedClient = __webpack_dev_server_client__.default; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-sockjs-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-sockjs-config/webpack.config.js deleted file mode 100644 index 661a14db435..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-sockjs-config/webpack.config.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-ws-config/foo.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-ws-config/foo.js deleted file mode 100644 index 538ae3e1b1f..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-ws-config/foo.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -// 'npm run prepare' must be run for this to work during testing -const WebsocketClient = - require("webpack-dev-server/client/clients/WebSocketClient").default; - -window.expectedClient = WebsocketClient; -// eslint-disable-next-line camelcase, no-undef -window.injectedClient = __webpack_dev_server_client__.default; diff --git a/packages/rspack-dev-server/tests/fixtures/provide-plugin-ws-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/provide-plugin-ws-config/webpack.config.js deleted file mode 100644 index 661a14db435..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/provide-plugin-ws-config/webpack.config.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/reload-config-2/foo.js b/packages/rspack-dev-server/tests/fixtures/reload-config-2/foo.js deleted file mode 100644 index 37887d25359..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/reload-config-2/foo.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; - -// eslint-disable-next-line import/no-unresolved -require("./main.css"); diff --git a/packages/rspack-dev-server/tests/fixtures/reload-config-2/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/reload-config-2/webpack.config.js deleted file mode 100644 index adb992fb269..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/reload-config-2/webpack.config.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - module: { - rules: [ - { - test: /\.css$/, - use: [{ loader: "style-loader" }, { loader: "css-loader" }] - } - ] - }, - node: false, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/reload-config/foo.js b/packages/rspack-dev-server/tests/fixtures/reload-config/foo.js deleted file mode 100644 index 68ad7bddf6e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/reload-config/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -require("./main.css"); diff --git a/packages/rspack-dev-server/tests/fixtures/reload-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/reload-config/webpack.config.js deleted file mode 100644 index f85af87b103..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/reload-config/webpack.config.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - entry: "./foo.js", - stats: "none", - output: { - path: "/" - }, - module: { - rules: [ - { - test: /\.css$/, - use: [{ loader: "style-loader" }, { loader: "css-loader" }] - } - ] - }, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/simple-config-other/foo.js b/packages/rspack-dev-server/tests/fixtures/simple-config-other/foo.js deleted file mode 100644 index fc6e46027d7..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/simple-config-other/foo.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -console.log( - "Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Very Long Line." -); diff --git a/packages/rspack-dev-server/tests/fixtures/simple-config-other/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/simple-config-other/webpack.config.js deleted file mode 100644 index 52a66fb467e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/simple-config-other/webpack.config.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/simple-config/foo.js b/packages/rspack-dev-server/tests/fixtures/simple-config/foo.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/simple-config/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/simple-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/simple-config/webpack.config.js deleted file mode 100644 index 661a14db435..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/simple-config/webpack.config.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - path: "/" - }, - node: false, - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/foo.js b/packages/rspack-dev-server/tests/fixtures/static-config/foo.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/other/foo.html b/packages/rspack-dev-server/tests/fixtures/static-config/other/foo.html deleted file mode 100644 index c57ed97e227..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/other/foo.html +++ /dev/null @@ -1 +0,0 @@ -Foo! diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/assets/example.txt b/packages/rspack-dev-server/tests/fixtures/static-config/public/assets/example.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/assets/other.txt b/packages/rspack-dev-server/tests/fixtures/static-config/public/assets/other.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/bar/index.html b/packages/rspack-dev-server/tests/fixtures/static-config/public/bar/index.html deleted file mode 100644 index 17654db5a15..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/public/bar/index.html +++ /dev/null @@ -1 +0,0 @@ -Heyo diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/foo.wasm b/packages/rspack-dev-server/tests/fixtures/static-config/public/foo.wasm deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/index.html b/packages/rspack-dev-server/tests/fixtures/static-config/public/index.html deleted file mode 100644 index 20f073ee9d7..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/public/index.html +++ /dev/null @@ -1 +0,0 @@ -Heyo. diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/node_modules/.gitkeep b/packages/rspack-dev-server/tests/fixtures/static-config/public/node_modules/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/node_modules/index.html b/packages/rspack-dev-server/tests/fixtures/static-config/public/node_modules/index.html deleted file mode 100644 index ba0e162e1c4..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/public/node_modules/index.html +++ /dev/null @@ -1 +0,0 @@ -bar \ No newline at end of file diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/public/other.html b/packages/rspack-dev-server/tests/fixtures/static-config/public/other.html deleted file mode 100644 index 6b31da1a64c..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/public/other.html +++ /dev/null @@ -1 +0,0 @@ -Other html diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/static/index.html b/packages/rspack-dev-server/tests/fixtures/static-config/static/index.html deleted file mode 100644 index 20f073ee9d7..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/static/index.html +++ /dev/null @@ -1 +0,0 @@ -Heyo. diff --git a/packages/rspack-dev-server/tests/fixtures/static-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/static-config/webpack.config.js deleted file mode 100644 index 71928769b24..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/static-config/webpack.config.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - publicPath: "/" - }, - infrastructureLogging: { - level: "warn" - } -}; diff --git a/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/browser.js b/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/browser.js deleted file mode 100644 index ddcebf29c76..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hello from the browser"); diff --git a/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/server.js b/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/server.js deleted file mode 100644 index 3dfb585f6d8..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/server.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hello from the server"); diff --git a/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/webpack.config.js deleted file mode 100644 index 1ddc7f280b5..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/universal-compiler-config/webpack.config.js +++ /dev/null @@ -1,43 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = [ - { - name: "browser", - mode: "development", - context: __dirname, - stats: "none", - entry: "./browser.js", - output: { - path: "/", - filename: "browser.js" - }, - plugins: [new HTMLGeneratorPlugin()], - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - } - }, - { - name: "server", - mode: "development", - context: __dirname, - target: "node", - stats: "none", - entry: "./server.js", - output: { - path: "/", - filename: "server.js" - }, - plugins: [new HTMLGeneratorPlugin()], - infrastructureLogging: { - level: "info", - stream: { - write: () => {} - } - } - } -]; diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/foo.js b/packages/rspack-dev-server/tests/fixtures/watch-files-config/foo.js deleted file mode 100644 index 3c915dbcb8e..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/watch-files-config/foo.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -console.log("Hey."); diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/other/foo.html b/packages/rspack-dev-server/tests/fixtures/watch-files-config/other/foo.html deleted file mode 100644 index c57ed97e227..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/watch-files-config/other/foo.html +++ /dev/null @@ -1 +0,0 @@ -Foo! diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/assets/example.txt b/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/assets/example.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/assets/non-exist.txt b/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/assets/non-exist.txt deleted file mode 100644 index 9c6e47bc1f0..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/assets/non-exist.txt +++ /dev/null @@ -1 +0,0 @@ -Kurosaki Ichigo \ No newline at end of file diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/assets/other.txt b/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/assets/other.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/bar/index.html b/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/bar/index.html deleted file mode 100644 index 17654db5a15..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/bar/index.html +++ /dev/null @@ -1 +0,0 @@ -Heyo diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/other.html b/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/other.html deleted file mode 100644 index 6b31da1a64c..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/watch-files-config/public/other.html +++ /dev/null @@ -1 +0,0 @@ -Other html diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/static/index.html b/packages/rspack-dev-server/tests/fixtures/watch-files-config/static/index.html deleted file mode 100644 index 20f073ee9d7..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/watch-files-config/static/index.html +++ /dev/null @@ -1 +0,0 @@ -Heyo. diff --git a/packages/rspack-dev-server/tests/fixtures/watch-files-config/webpack.config.js b/packages/rspack-dev-server/tests/fixtures/watch-files-config/webpack.config.js deleted file mode 100644 index 7df3e7e4dbb..00000000000 --- a/packages/rspack-dev-server/tests/fixtures/watch-files-config/webpack.config.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - -module.exports = { - mode: "development", - context: __dirname, - stats: "none", - entry: "./foo.js", - output: { - publicPath: "/" - }, - infrastructureLogging: { - level: "warn" - }, - plugins: [new HTMLGeneratorPlugin()] -}; diff --git a/packages/rspack-dev-server/tests/helpers/conditional-test.js b/packages/rspack-dev-server/tests/helpers/conditional-test.js deleted file mode 100644 index 5d0ba713c62..00000000000 --- a/packages/rspack-dev-server/tests/helpers/conditional-test.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -const isWindows = process.platform === "win32"; - -function skipTestOnWindows(reason) { - if (isWindows) { - test.skip(reason, () => {}); - } - return isWindows; -} - -module.exports.skipTestOnWindows = skipTestOnWindows; diff --git a/packages/rspack-dev-server/tests/helpers/custom-http.js b/packages/rspack-dev-server/tests/helpers/custom-http.js deleted file mode 100644 index 0678c55d9a3..00000000000 --- a/packages/rspack-dev-server/tests/helpers/custom-http.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -const customHTTP = require("http"); - -module.exports = customHTTP; diff --git a/packages/rspack-dev-server/tests/helpers/get-port.js b/packages/rspack-dev-server/tests/helpers/get-port.js deleted file mode 100644 index 05898a793de..00000000000 --- a/packages/rspack-dev-server/tests/helpers/get-port.js +++ /dev/null @@ -1,133 +0,0 @@ -"use strict"; - -/* - * Based on the packages get-port https://www.npmjs.com/package/get-port - * and portfinder https://www.npmjs.com/package/portfinder - * The code structure is similar to get-port, but it searches - * ports deterministically like portfinder - */ -const net = require("net"); -const os = require("os"); - -const minPort = 1024; -const maxPort = 65_535; - -/** - * @return {Set} - */ -const getLocalHosts = () => { - const interfaces = os.networkInterfaces(); - - // Add undefined value for createServer function to use default host, - // and default IPv4 host in case createServer defaults to IPv6. - // eslint-disable-next-line no-undefined - const results = new Set([undefined, "0.0.0.0"]); - - for (const _interface of Object.values(interfaces)) { - if (_interface) { - for (const config of _interface) { - results.add(config.address); - } - } - } - - return results; -}; - -/** - * @param {number} basePort - * @param {string | undefined} host - * @return {Promise} - */ -const checkAvailablePort = (basePort, host) => - new Promise((resolve, reject) => { - const server = net.createServer(); - server.unref(); - server.on("error", reject); - - server.listen(basePort, host, () => { - // Next line should return AddressInfo because we're calling it after listen() and before close() - const { port } = /** @type {import("net").AddressInfo} */ ( - server.address() - ); - server.close(() => { - resolve(port); - }); - }); - }); - -/** - * @param {number} port - * @param {Set} hosts - * @return {Promise} - */ -const getAvailablePort = async (port, hosts) => { - /** - * Errors that mean that host is not available. - * @type {Set} - */ - const nonExistentInterfaceErrors = new Set(["EADDRNOTAVAIL", "EINVAL"]); - /* Check if the post is available on every local host name */ - for (const host of hosts) { - try { - await checkAvailablePort(port, host); // eslint-disable-line no-await-in-loop - } catch (error) { - /* We throw an error only if the interface exists */ - if ( - !nonExistentInterfaceErrors.has( - /** @type {NodeJS.ErrnoException} */ (error).code - ) - ) { - throw error; - } - } - } - - return port; -}; - -/** - * @param {number} basePort - * @param {string=} host - * @return {Promise} - */ -async function getPorts(basePort, host) { - if (basePort < minPort || basePort > maxPort) { - throw new Error(`Port number must lie between ${minPort} and ${maxPort}`); - } - - let port = basePort; - const localhosts = getLocalHosts(); - let hosts; - if (host && !localhosts.has(host)) { - hosts = new Set([host]); - } else { - /* If the host is equivalent to localhost - we need to check every equivalent host - else the port might falsely appear as available - on some operating systems */ - hosts = localhosts; - } - /** @type {Set} */ - const portUnavailableErrors = new Set(["EADDRINUSE", "EACCES"]); - while (port <= maxPort) { - try { - const availablePort = await getAvailablePort(port, hosts); // eslint-disable-line no-await-in-loop - return availablePort; - } catch (error) { - /* Try next port if port is busy; throw for any other error */ - if ( - !portUnavailableErrors.has( - /** @type {NodeJS.ErrnoException} */ (error).code - ) - ) { - throw error; - } - port += 1; - } - } - - throw new Error("No available ports found"); -} - -module.exports = getPorts; diff --git a/packages/rspack-dev-server/tests/helpers/global-setup-test.js b/packages/rspack-dev-server/tests/helpers/global-setup-test.js deleted file mode 100644 index 744d26da6f4..00000000000 --- a/packages/rspack-dev-server/tests/helpers/global-setup-test.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -// eslint-disable-next-line import/no-extraneous-dependencies -const tcpPortUsed = require("tcp-port-used"); -const { webpackVersion } = require("@rspack/core/package.json"); -const ports = require("./ports-map"); - -// eslint-disable-next-line no-console -console.log(`\n Running tests for webpack @${webpackVersion} \n`); - -async function validatePorts() { - const samples = []; - - Object.keys(ports).forEach(key => { - const value = ports[key]; - const arr = Array.isArray(value) ? value : [value]; - - arr.forEach(port => { - const check = tcpPortUsed.check(port, "localhost").then(inUse => { - if (inUse) { - throw new Error(`${port} has already used. [${key}]`); - } - }); - - samples.push(check); - }); - }); - - try { - await Promise.all(samples); - } catch (e) { - // eslint-disable-next-line no-console - console.error(e); - process.exit(1); - } -} - -module.exports = validatePorts; diff --git a/packages/rspack-dev-server/tests/helpers/html-generator-plugin.js b/packages/rspack-dev-server/tests/helpers/html-generator-plugin.js deleted file mode 100644 index e8da3b941ac..00000000000 --- a/packages/rspack-dev-server/tests/helpers/html-generator-plugin.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; - -const HTMLContentForIndex = ` - - - - - webpack-dev-server - - -

webpack-dev-server is running...

- - - -`; - -const HTMLContentForAssets = assetName => ` - - - - - webpack-dev-server - - -

(${assetName}>)webpack-dev-server is running...

- - - -`; - -const HTMLContentForTest = ` - - - - - test - - -

Created via HTMLGeneratorPlugin

- - -`; - -module.exports = class HTMLGeneratorPlugin { - // eslint-disable-next-line class-methods-use-this - apply(compiler) { - const pluginName = "html-generator-plugin"; - - compiler.hooks.thisCompilation.tap(pluginName, compilation => { - const { RawSource } = compiler.webpack.sources; - - compilation.hooks.processAssets.tap( - { - name: pluginName, - stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL - }, - () => { - const indexSource = new RawSource(HTMLContentForIndex); - const testSource = new RawSource(HTMLContentForTest); - const assets = compilation.getAssets(); - - compilation.emitAsset("index.html", indexSource); - compilation.emitAsset("test.html", testSource); - - for (const asset of assets) { - const assetName = asset.name; - - if (assetName !== "main.js" && assetName.endsWith(".js")) { - const assetSource = new RawSource( - HTMLContentForAssets(assetName) - ); - compilation.emitAsset( - assetName.replace(".js", ".html"), - assetSource - ); - } - } - } - ); - }); - } -}; diff --git a/packages/rspack-dev-server/tests/helpers/normalize-options.js b/packages/rspack-dev-server/tests/helpers/normalize-options.js deleted file mode 100644 index 46e58720084..00000000000 --- a/packages/rspack-dev-server/tests/helpers/normalize-options.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -function normalizeOptions(options) { - const normalizedOptions = {}; - - // eslint-disable-next-line guard-for-in - for (const propertyName in options) { - let value = options[propertyName]; - - if (Array.isArray(value)) { - value = value.map(item => { - if (Buffer.isBuffer(item)) { - return ""; - } else if ( - typeof item.pem !== "undefined" && - Buffer.isBuffer(item.pem) - ) { - item.pem = ""; - } else if ( - typeof item.buf !== "undefined" && - Buffer.isBuffer(item.buf) - ) { - item.buf = ""; - } - - return item; - }); - } else if (Buffer.isBuffer(value)) { - value = ""; - } - - normalizedOptions[propertyName] = value; - } - - return normalizedOptions; -} - -module.exports = normalizeOptions; diff --git a/packages/rspack-dev-server/tests/helpers/normalize.js b/packages/rspack-dev-server/tests/helpers/normalize.js deleted file mode 100644 index 092911a4123..00000000000 --- a/packages/rspack-dev-server/tests/helpers/normalize.js +++ /dev/null @@ -1,49 +0,0 @@ -const path = require("path"); - -const CURRENT_CWD = process.cwd(); -const ROOT = path.resolve(__dirname, "../../../../"); - -const quoteMeta = str => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&"); -const cwdRegExp = new RegExp( - `${quoteMeta(CURRENT_CWD)}((?:\\\\)?(?:[a-zA-Z.\\-_]+\\\\)*)`, - "g" -); -const escapedCwd = JSON.stringify(CURRENT_CWD).slice(1, -1); -const escapedCwdRegExp = new RegExp( - `${quoteMeta(escapedCwd)}((?:\\\\\\\\)?(?:[a-zA-Z.\\-_]+\\\\\\\\)*)`, - "g" -); -const normalize = str => { - let normalizedStr = str; - if (CURRENT_CWD.startsWith("/")) { - normalizedStr = normalizedStr.replace( - new RegExp(quoteMeta(CURRENT_CWD), "g"), - "" - ); - } else { - normalizedStr = normalizedStr.replace( - cwdRegExp, - (_, g) => `${g.replace(/\\/g, "/")}` - ); - normalizedStr = normalizedStr.replace( - escapedCwdRegExp, - (_, g) => `${g.replace(/\\\\/g, "/")}` - ); - } - normalizedStr = normalizedStr.split(ROOT).join(""); - normalizedStr = normalizedStr.replace(/:\d+:\d+/g, "::"); - normalizedStr = normalizedStr.replace( - /@@ -\d+,\d+ \+\d+,\d+ @@/g, - "@@ ... @@" - ); - return normalizedStr; -}; - -expect.addSnapshotSerializer({ - test(value) { - return typeof value === "string"; - }, - print(received) { - return normalize(received); - } -}); diff --git a/packages/rspack-dev-server/tests/helpers/ports-map.js b/packages/rspack-dev-server/tests/helpers/ports-map.js deleted file mode 100644 index 9303e57ef00..00000000000 --- a/packages/rspack-dev-server/tests/helpers/ports-map.js +++ /dev/null @@ -1,119 +0,0 @@ -"use strict"; - -// important: new port mappings must be added to the bottom of this list -const listOfTests = { - // CLI tests - "cli-basic": 1, - "cli-port-option": 1, - // e2e tests - bundle: 1, - "sockjs-client": 1, - "web-socket-client": 1, - "hot-and-live-reload": 1, - logging: 1, - overlay: 1, - progress: 1, - "server-and-client-transport": 1, - "web-socket-server-url": 2, - // integration tests - "module-federation": 1, - "multi-compiler": 1, - // unit tests - bonjour: 1, - "client-option": 1, - "compress-option": 1, - "headers-option": 1, - "history-api-fallback-option": 1, - "host-option": 1, - "hot-option": 1, - "http2-option": 1, - "https-option": 1, - "mime-types-option": 1, - "magic-html-option": 1, - "on-after-setup-middleware-option": 1, - "on-before-setup-middleware-option": 1, - "on-listening-option": 1, - "open-option": 1, - "port-option": 1, - "proxy-option": 4, - server: 1, - "setup-exit-signals-option": 1, - "static-directory-option": 1, - "static-public-path-option": 1, - "stats-option": 1, - "watch-files-option": 1, - "web-socket-server-option": 1, - "sockjs-server": 1, - "web-socket-server": 1, - routes: 1, - "web-socket-communication": 1, - ipc: 1, - stats: 1, - "cli-allowed-hosts": 1, - "cli-bonjour": 1, - "cli-client": 1, - "cli-colors": 1, - "cli-compress": 1, - "cli-history-api-fallback": 1, - "cli-host": 1, - "cli-hot": 1, - "cli-http2": 1, - "cli-https": 1, - "cli-live-reload": 1, - "cli-magic-html": 1, - "cli-open": 1, - "cli-static": 1, - "cli-watch-files": 1, - "cli-web-socket-server": 1, - target: 1, - entry: 1, - "allowed-hosts": 2, - host: 1, - api: 1, - "lazy-compilation": 1, - "range-header": 1, - port: 1, - "web-socket-server-test": 1, - "client-reconnect-option": 1, - "cli-server": 1, - "server-option": 1, - "normalize-option": 1, - "setup-middlewares-option": 1, - "options-request-response": 2, - app: 1 -}; - -let startPort = 8089; - -const ports = {}; - -Object.keys(listOfTests).forEach(key => { - const value = listOfTests[key]; - - ports[key] = - value === 1 - ? (startPort += 1) - : [...new Array(value)].map(() => (startPort += 1)); -}); - -const busy = {}; - -module.exports = new Proxy(ports, { - get(target, name) { - if (!target[name]) { - throw new Error( - `Requested "${name}" port(s) for tests not found, please update "test/ports-map.js".` - ); - } - - if (busy[name]) { - throw new Error( - `The "${name}" port is already in use in another test, please add a new one.` - ); - } - - busy[name] = true; - - return target[name]; - } -}); diff --git a/packages/rspack-dev-server/tests/helpers/puppeteer-constants.js b/packages/rspack-dev-server/tests/helpers/puppeteer-constants.js deleted file mode 100644 index 4c8f3d8eacd..00000000000 --- a/packages/rspack-dev-server/tests/helpers/puppeteer-constants.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; - -module.exports = { - reloadReadyDelay: 5000, - completeReloadDelay: 10000, - initConsoleDelay: 3000, - awaitServerCloseDelay: 1000, - beforeBrowserCloseDelay: 3000, - puppeteerArgs: [ - "--disable-background-timer-throttling", - "--disable-breakpad", - "--disable-client-side-phishing-detection", - "--disable-cloud-import", - "--disable-default-apps", - "--disable-dev-shm-usage", - "--disable-extensions", - "--disable-gesture-typing", - "--disable-hang-monitor", - "--disable-infobars", - "--disable-notifications", - "--disable-offer-store-unmasked-wallet-cards", - "--disable-offer-upload-credit-cards", - "--disable-popup-blocking", - "--disable-print-preview", - "--disable-prompt-on-repost", - "--disable-setuid-sandbox", - "--disable-speech-api", - "--disable-sync", - "--disable-tab-for-desktop-share", - "--disable-translate", - "--disable-voice-input", - "--disable-wake-on-wifi", - "--enable-async-dns", - "--enable-simple-cache-backend", - "--enable-tcp-fast-open", - "--enable-webgl", - "--hide-scrollbars", - "--ignore-gpu-blacklist", - "--media-cache-size=33554432", - "--metrics-recording-only", - "--mute-audio", - "--no-default-browser-check", - "--no-first-run", - "--no-pings", - "--no-sandbox", - "--no-zygote", - "--password-store=basic", - "--prerender-from-omnibox=disabled", - "--use-gl=swiftshader", - "--use-mock-keychain", - "--disable-field-trial-config" - ] -}; diff --git a/packages/rspack-dev-server/tests/helpers/run-browser.js b/packages/rspack-dev-server/tests/helpers/run-browser.js deleted file mode 100644 index 91948e023fd..00000000000 --- a/packages/rspack-dev-server/tests/helpers/run-browser.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; - -const puppeteer = require("puppeteer"); -const { puppeteerArgs } = require("./puppeteer-constants"); - -/** - * @typedef {Object} RunBrowserResult - * @property {import('puppeteer').Page} page - * @property {import('puppeteer').Browser} browser - */ - -/** - * @param {Parameters[0]} config - * @returns {Promise} - */ -function runBrowser(config) { - return new Promise((resolve, reject) => { - /** - * @type {import('puppeteer').Page} - */ - let page; - /** - * @type {import('puppeteer').Browser} - */ - let browser; - - puppeteer - .launch({ - headless: "new", - // because of invalid localhost certificate - acceptInsecureCerts: true, - // args come from: https://github.com/alixaxel/chrome-aws-lambda/blob/master/source/index.js - args: puppeteerArgs - }) - .then(launchedBrowser => { - browser = launchedBrowser; - - return runPage(launchedBrowser, config); - }) - .then(newPage => { - page = newPage; - - resolve({ page, browser }); - }) - .catch(reject); - }); -} - -function runPage(browser, config) { - /** - * @type {import('puppeteer').Page} - */ - let page; - - const options = { - viewport: { - width: 500, - height: 500 - }, - userAgent: "", - ...config - }; - - return Promise.resolve() - .then(() => browser.newPage()) - .then(newPage => { - page = newPage; - page.emulate(options); - - return page.setRequestInterception(true); - }) - .then(() => { - page.on("request", interceptedRequest => { - if (interceptedRequest.isInterceptResolutionHandled()) return; - if (interceptedRequest.url().includes("favicon.ico")) { - interceptedRequest.respond({ - status: 200, - contentType: "image/png", - body: "Empty" - }); - } else { - interceptedRequest.continue( - interceptedRequest.continueRequestOverrides(), - 10 - ); - } - }); - - return page; - }); -} - -module.exports = runBrowser; -module.exports.runPage = runPage; diff --git a/packages/rspack-dev-server/tests/helpers/sequencer.js b/packages/rspack-dev-server/tests/helpers/sequencer.js deleted file mode 100644 index b813fa33208..00000000000 --- a/packages/rspack-dev-server/tests/helpers/sequencer.js +++ /dev/null @@ -1,10 +0,0 @@ -const Sequencer = require("@jest/test-sequencer").default; - -class NamedSequencer extends Sequencer { - sort(tests) { - const copyTests = [...tests]; - return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); - } -} - -module.exports = NamedSequencer; diff --git a/packages/rspack-dev-server/tests/helpers/session-subscribe.js b/packages/rspack-dev-server/tests/helpers/session-subscribe.js deleted file mode 100644 index 5d079a0eae2..00000000000 --- a/packages/rspack-dev-server/tests/helpers/session-subscribe.js +++ /dev/null @@ -1,9 +0,0 @@ -"use strict"; - -module.exports = async function sessionSubscribe(session) { - session.on("sessionattached", s => { - sessionSubscribe(s); - }); - session.send("Network.enable"); - session.send("Runtime.runIfWaitingForDebugger"); -}; diff --git a/packages/rspack-dev-server/tests/helpers/setup-test.js b/packages/rspack-dev-server/tests/helpers/setup-test.js deleted file mode 100644 index 99a74a59bfe..00000000000 --- a/packages/rspack-dev-server/tests/helpers/setup-test.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -process.env.CHOKIDAR_USEPOLLING = true; - -jest.setTimeout(400000); diff --git a/packages/rspack-dev-server/tests/helpers/snapshot-resolver.js b/packages/rspack-dev-server/tests/helpers/snapshot-resolver.js deleted file mode 100644 index 0a17d51a6f4..00000000000 --- a/packages/rspack-dev-server/tests/helpers/snapshot-resolver.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -const path = require("path"); -const webpack = require("webpack"); - -const [webpackVersion] = webpack.version; -const snapshotExtension = `.snap.webpack${webpackVersion}`; - -module.exports = { - resolveSnapshotPath: testPath => - path.join( - path.dirname(testPath), - "__snapshots__", - `${path.basename(testPath)}${snapshotExtension}` - ), - resolveTestPath: snapshotPath => - snapshotPath - .replace(`${path.sep}__snapshots__`, "") - .slice(0, -snapshotExtension.length), - testPathForConsistencyCheck: path.join( - "consistency_check", - "__tests__", - "example.test.js" - ) -}; diff --git a/packages/rspack-dev-server/tests/helpers/test-server.js b/packages/rspack-dev-server/tests/helpers/test-server.js deleted file mode 100644 index 027acd741b4..00000000000 --- a/packages/rspack-dev-server/tests/helpers/test-server.js +++ /dev/null @@ -1,95 +0,0 @@ -"use strict"; - -const webpack = require("webpack"); -const { RspackDevServer: Server } = require("@rspack/dev-server"); - -let server; - -// start server, returning the full setup of the server -// (both the server and the compiler) -function startFullSetup(config, options, done) { - // disable watching by default for tests - if (typeof options.static === "undefined") { - options.static = false; - } else if (options.static === null) { - // this provides a way of using the default static value - delete options.static; - } - - const compiler = webpack(config); - - server = new Server(options, compiler); - - server.startCallback(error => { - if (error && done) { - return done(error); - } - - if (done) { - done(); - } - }); - - return { - server, - compiler - }; -} - -function startAwaitingCompilationFullSetup(config, options, done) { - let readyCount = 0; - - const ready = error => { - if (error && done) { - done(error); - - return; - } - - readyCount += 1; - - if (readyCount === 2) { - done(); - } - }; - - const fullSetup = startFullSetup(config, options, ready); - - // wait for compilation, since dev server can start before this - // https://github.com/webpack/webpack-dev-server/issues/847 - fullSetup.compiler.hooks.done.tap("done", () => { - ready(); - }); - - return fullSetup; -} - -function startAwaitingCompilation(config, options, done) { - return startAwaitingCompilationFullSetup(config, options, done).server; -} - -function start(config, options, done) { - // I suspect that almost all tests need to wait for compilation to - // finish, because not doing so leaves open handles for jest, - // in the case where a compilation didn't finish before destroying - // the server and moving on. Thus, the default "start" should wait - // for compilation, and only special cases where you don't expect - // a compilation happen should use startBeforeCompilation - return startAwaitingCompilation(config, options, done); -} - -function close(done) { - if (server) { - server.stopCallback(() => { - server = null; - done(); - }); - } else { - done(); - } -} - -module.exports = { - start, - close -}; diff --git a/packages/rspack-dev-server/tests/helpers/trusted-types-html-generator-plugin.js b/packages/rspack-dev-server/tests/helpers/trusted-types-html-generator-plugin.js deleted file mode 100644 index ee647d3d4ef..00000000000 --- a/packages/rspack-dev-server/tests/helpers/trusted-types-html-generator-plugin.js +++ /dev/null @@ -1,82 +0,0 @@ -"use strict"; - -const HTMLContentForIndex = ` - - - - - - webpack-dev-server - - -

webpack-dev-server is running...

- - - -`; - -const HTMLContentForTest = ` - - - - - - test - - -

Created via HTMLGeneratorPlugin

- - -`; - -module.exports = class HTMLGeneratorPlugin { - // eslint-disable-next-line class-methods-use-this - apply(compiler) { - const pluginName = "html-generator-plugin"; - - compiler.hooks.thisCompilation.tap(pluginName, compilation => { - if (compiler.webpack) { - const { RawSource } = compiler.webpack.sources; - - compilation.hooks.processAssets.tap( - { - name: pluginName, - stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL - }, - () => { - const indexSource = new RawSource(HTMLContentForIndex); - const testSource = new RawSource(HTMLContentForTest); - - compilation.emitAsset("index.html", indexSource); - compilation.emitAsset("test.html", testSource); - } - ); - } else { - compilation.hooks.additionalAssets.tap(pluginName, () => { - compilation.emitAsset("index.html", { - source() { - return HTMLContentForIndex; - }, - size() { - return HTMLContentForIndex.length; - } - }); - compilation.emitAsset("test.html", { - source() { - return HTMLContentForTest; - }, - size() { - return HTMLContentForTest.length; - } - }); - }); - } - }); - } -}; diff --git a/packages/rspack-dev-server/tests/normalizeOptions.test.ts b/packages/rspack-dev-server/tests/normalizeOptions.test.ts deleted file mode 100644 index 412e0e65b78..00000000000 --- a/packages/rspack-dev-server/tests/normalizeOptions.test.ts +++ /dev/null @@ -1,182 +0,0 @@ -import { RspackOptions, rspack } from "@rspack/core"; -import { Configuration, RspackDevServer } from "@rspack/dev-server"; -import ReactRefreshPlugin from "@rspack/plugin-react-refresh"; -// @ts-expect-error -import serializer from "jest-serializer-path"; -import customConfig from "./fixtures/provide-plugin-custom/webpack.config"; - -expect.addSnapshotSerializer(serializer); - -// The aims of use a cutstom value rather than -// default is to avoid stack overflow trigged -// by `webpack/schemas/WebpackOption.check.js` in debug mode -const ENTRY = "./placeholder.js"; -const ENTRY1 = "./placeholder1.js"; - -// TODO: node 20 works but node 18 and 16 failed -describe.skip("normalize options snapshot", () => { - it("no options", async () => { - await match({}); - }); - - it("port string", async () => { - await match({ - devServer: { - port: "9000" - } - }); - }); - - it("additional entires should added", async () => { - expect( - await getAdditionEntries({}, { entry: ["something"] }) - ).toMatchSnapshot(); - }); - - it("shouldn't have reactRefreshEntry.js by default when in production mode", async () => { - const reactRefreshEntry = - "plugin-react-refresh/client/reactRefreshEntry.js"; - const entries1 = await getAdditionEntries( - {}, - { - mode: "production", - entry: ["something"] - } - ); - expect(entries1["undefined"]).not.toContain(reactRefreshEntry); - const entries2 = await getAdditionEntries( - {}, - { - mode: "production", - entry: ["something"], - plugins: [new ReactRefreshPlugin({ forceEnable: true })] - } - ); - expect(entries2["undefined"]).toContain(reactRefreshEntry); - const entries3 = await getAdditionEntries( - {}, - { - mode: "development", - entry: ["something"], - plugins: [new ReactRefreshPlugin()] - } - ); - expect(entries3["undefined"]).toContain(reactRefreshEntry); - const entries4 = await getAdditionEntries( - {}, - { - mode: "production", - entry: ["something"], - plugins: [new ReactRefreshPlugin()] - } - ); - expect(entries4["undefined"]).not.toContain(reactRefreshEntry); - }); - - it("should apply HMR plugin by default", async () => { - const compiler = rspack({ - entry: ENTRY, - stats: "none" - }); - const server = new RspackDevServer({}, compiler); - await server.start(); - const hmrPlugins = compiler.__internal__builtinPlugins.filter( - p => p.name === "HotModuleReplacementPlugin" - ); - expect(hmrPlugins.length).toBe(1); - expect(server.options.hot).toBe(true); - await server.stop(); - }); - - it("should support multi-compiler", async () => { - const compiler = rspack([ - { - entry: ENTRY, - stats: "none" - }, - { - entry: ENTRY1, - stats: "none" - } - ]); - const server = new RspackDevServer({}, compiler); - await server.start(); - await server.stop(); - }); - - it("should support custom client transport", async () => { - const compiler = rspack(customConfig); - const devServerOptions = { - client: { - webSocketTransport: require.resolve( - "./fixtures/custom-client/CustomSockJSClient" - ) - }, - webSocketServer: "sockjs" - }; - const server = new RspackDevServer(devServerOptions, compiler); - await server.start(); - await server.stop(); - }); -}); - -async function match(config: RspackOptions) { - const compiler = rspack({ - ...config, - entry: ENTRY, - stats: "none" - }); - const server = new RspackDevServer( - compiler.options.devServer ?? {}, - compiler - ); - await server.start(); - // it will break ci - //@ts-ignore - delete server.options.port; - expect(server.options).toMatchSnapshot(); - await server.stop(); -} - -async function getAdditionEntries( - serverConfig: Configuration, - config: RspackOptions -) { - const compiler = rspack({ - ...config, - stats: "none", - entry: ENTRY - }); - - const server = new RspackDevServer(serverConfig, compiler); - await server.start(); - const entries = compiler.__internal__builtinPlugins - .filter(p => p.name === "EntryPlugin") - .map(p => p.options) - .reduce((acc: any, cur: any) => { - const name = cur.options.name; - const request = cur.entry; - if (acc[name]) { - acc[name].import.push(request); - } else { - acc[name] = { import: [request] }; - } - return acc; - }, {}); - // some hack for snapshot - const value = Object.fromEntries( - Object.entries(entries).map(([key, item]) => { - // @ts-expect-error - const replaced = item.import?.map(entry => { - const array = entry - .replace(/\\/g, "/") - .replace(/port=\d+/g, "") - .split("/"); - return "" + "/" + array.slice(-3).join("/"); - }); - return [key, replaced]; - }) - ); - await server.stop(); - return value; -} diff --git a/packages/rspack-dev-server/tests/placeholder.js b/packages/rspack-dev-server/tests/placeholder.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/placeholder1.js b/packages/rspack-dev-server/tests/placeholder1.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/rspack-dev-server/tests/tsconfig.json b/packages/rspack-dev-server/tests/tsconfig.json deleted file mode 100644 index 767ff2dc552..00000000000 --- a/packages/rspack-dev-server/tests/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": false, - "rootDir": "../" - }, - "include": ["../src", "../tests"], - "references": [] -} diff --git a/packages/rspack-dev-server/tsconfig.build.json b/packages/rspack-dev-server/tsconfig.build.json deleted file mode 100644 index 5a66a9d9a93..00000000000 --- a/packages/rspack-dev-server/tsconfig.build.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "sourceMap": false, - "declarationMap": false, - }, - "references": [] -} diff --git a/packages/rspack-dev-server/tsconfig.json b/packages/rspack-dev-server/tsconfig.json deleted file mode 100644 index b6082525267..00000000000 --- a/packages/rspack-dev-server/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "outDir": "dist", - "rootDir": "src", - "resolveJsonModule": true - }, - "include": ["src"] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18c649dce14..79d26dd86c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -304,8 +304,8 @@ importers: specifier: workspace:* version: link:../rspack '@rspack/dev-server': - specifier: workspace:* - version: link:../rspack-dev-server + specifier: 1.0.6 + version: 1.0.6(@rspack/core@packages+rspack)(@types/express@4.17.21)(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0))) '@rspack/plugin-react-refresh': specifier: 1.0.0 version: 1.0.0(react-refresh@0.14.0) @@ -443,8 +443,8 @@ importers: specifier: ^0.5.7 version: 0.5.7 '@rspack/dev-server': - specifier: workspace:* - version: link:../rspack-dev-server + specifier: 1.0.6 + version: 1.0.6(@rspack/core@packages+rspack)(@types/express@4.17.21)(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0))) colorette: specifier: 2.0.19 version: 2.0.19 @@ -504,100 +504,6 @@ importers: specifier: 5.0.2 version: 5.0.2 - packages/rspack-dev-server: - dependencies: - chokidar: - specifier: ^3.6.0 - version: 3.6.0 - connect-history-api-fallback: - specifier: ^2.0.0 - version: 2.0.0 - express: - specifier: ^4.19.2 - version: 4.19.2 - http-proxy-middleware: - specifier: ^2.0.6 - version: 2.0.6(@types/express@4.17.21) - mime-types: - specifier: ^2.1.35 - version: 2.1.35 - p-retry: - specifier: 4.6.2 - version: 4.6.2 - webpack-dev-middleware: - specifier: ^7.4.2 - version: 7.4.2(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0))) - webpack-dev-server: - specifier: 5.0.4 - version: 5.0.4(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0))) - ws: - specifier: ^8.16.0 - version: 8.17.1 - devDependencies: - '@jest/test-sequencer': - specifier: ^29.7.0 - version: 29.7.0 - '@rspack/core': - specifier: workspace:* - version: link:../rspack - '@rspack/dev-server': - specifier: workspace:* - version: 'link:' - '@rspack/plugin-react-refresh': - specifier: 1.0.0 - version: 1.0.0(react-refresh@0.14.0) - '@types/connect-history-api-fallback': - specifier: 1.5.4 - version: 1.5.4 - '@types/express': - specifier: 4.17.21 - version: 4.17.21 - '@types/mime-types': - specifier: 2.1.4 - version: 2.1.4 - '@types/ws': - specifier: 8.5.10 - version: 8.5.10 - css-loader: - specifier: ^6.11.0 - version: 6.11.0(@rspack/core@packages+rspack)(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0))) - graceful-fs: - specifier: 4.2.10 - version: 4.2.10(patch_hash=ivtm2a2cfr5pomcfbedhmr5v2q) - http-proxy: - specifier: ^1.18.1 - version: 1.18.1 - jest-serializer-path: - specifier: ^0.1.15 - version: 0.1.15 - prettier: - specifier: 3.2.5 - version: 3.2.5 - puppeteer: - specifier: ^23.2.2 - version: 23.3.0(typescript@5.0.2) - require-from-string: - specifier: ^2.0.2 - version: 2.0.2 - sockjs-client: - specifier: ^1.6.1 - version: 1.6.1 - style-loader: - specifier: ^3.3.3 - version: 3.3.4(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0))) - supertest: - specifier: ^6.1.3 - version: 6.3.4 - tcp-port-used: - specifier: ^1.0.2 - version: 1.0.2 - typescript: - specifier: 5.0.2 - version: 5.0.2 - wait-for-expect: - specifier: ^3.0.2 - version: 3.0.2 - packages/rspack-test-tools: dependencies: '@babel/generator': @@ -1051,7 +957,7 @@ importers: version: 3.36.1 css-loader: specifier: ^6.11.0 - version: 6.11.0(@rspack/core@1.0.4)(webpack@5.94.0(webpack-cli@5.1.4)) + version: 6.11.0(@rspack/core@1.0.5)(webpack@5.94.0(webpack-cli@5.1.4)) date-fns: specifier: ^2.29.3 version: 2.30.0 @@ -2819,11 +2725,6 @@ packages: '@prefresh/utils@1.2.0': resolution: {integrity: sha512-KtC/fZw+oqtwOLUFM9UtiitB0JsVX0zLKNyRTA332sqREqSALIIQQxdUCS1P3xR/jT1e2e8/5rwH6gdcMLEmsQ==} - '@puppeteer/browsers@2.4.0': - resolution: {integrity: sha512-x8J1csfIygOwf6D6qUAZ0ASk3z63zPb7wkNeHRerCMh82qWKUrOgkuP005AJC8lDL6/evtXETGEJVcwykKT4/g==} - engines: {node: '>=18'} - hasBin: true - '@rollup/rollup-android-arm-eabi@4.17.2': resolution: {integrity: sha512-NM0jFxY8bB8QLkoKxIQeObCaDlJKewVlIEkuyYKm5An1tdVZ966w2+MPQ2l8LBZLjR+SgyV+nRkTIunzOYBMLQ==} cpu: [arm] @@ -2927,8 +2828,8 @@ packages: cpu: [arm64] os: [darwin] - '@rspack/binding-darwin-arm64@1.0.4': - resolution: {integrity: sha512-HR4OVarDhLYAd3GRus26mGjaoEkvFGSdhRHWPXkTqPWT1QIx+cMTDe2dUnEb/CZyvpH0afLBlVHrxqUBNiLT/Q==} + '@rspack/binding-darwin-arm64@1.0.5': + resolution: {integrity: sha512-pEHj4AOluOa7FaR1DMACPUUZKO3qZI4/66xaTqk0BbclvMT7eheQAWtkmjdE9WJgeZ389TrwZeaMzzPdHhK/6Q==} cpu: [arm64] os: [darwin] @@ -2937,8 +2838,8 @@ packages: cpu: [x64] os: [darwin] - '@rspack/binding-darwin-x64@1.0.4': - resolution: {integrity: sha512-3L/vrzrcBpg1h7SqD+9m7CB0UlkDt3aOyJGZc0vwLOQM8IezRsawEoidyN9KyYhpDzBZHzLAUnsva33BcbFJYQ==} + '@rspack/binding-darwin-x64@1.0.5': + resolution: {integrity: sha512-xS5EDD9l3MHL54bnmxsndm61P9l3l7ZNuLSuPl2MbYJzDqPdnXhTdkIjdcDOLH2daFm8gfB634wa5knZhPGLOw==} cpu: [x64] os: [darwin] @@ -2947,8 +2848,8 @@ packages: cpu: [arm64] os: [linux] - '@rspack/binding-linux-arm64-gnu@1.0.4': - resolution: {integrity: sha512-Ggo2tLJKOFNsdcg9H3eYSUy03Wrq0PMVIlm50p/LLAMlfYm3kxBDNv7fP13fxlUe/oqXtFcVOlmMezbMH4oz8w==} + '@rspack/binding-linux-arm64-gnu@1.0.5': + resolution: {integrity: sha512-svPOFlem7s6T33tX8a28uD5Ngc7bdML96ioiH7Fhi0J/at+WAthor4GeUNwkwuzBQI/Nc9XCgiYPcE0pzP7c6w==} cpu: [arm64] os: [linux] @@ -2957,8 +2858,8 @@ packages: cpu: [arm64] os: [linux] - '@rspack/binding-linux-arm64-musl@1.0.4': - resolution: {integrity: sha512-2FeDh8/THJTH2N4XpFC9oRvdDlkOw6bQ+vS8x1jLUXj+CDwqmUiECjh+78o4qwe1EH2egWDmkq84RQ+KoR37mQ==} + '@rspack/binding-linux-arm64-musl@1.0.5': + resolution: {integrity: sha512-cysqogEUNc0TgzzXcK9bkv12eoCjqhLzOvGXQU1zSEU9Hov7tuzMDl3Z6R3A7NgOCmWu84/wOnTrkSOI28caew==} cpu: [arm64] os: [linux] @@ -2967,8 +2868,8 @@ packages: cpu: [x64] os: [linux] - '@rspack/binding-linux-x64-gnu@1.0.4': - resolution: {integrity: sha512-k2YQ579fDfXBw4KJMvZQQPShFUSln7wqtG59ltNLBejgFSxOtlMfLhY5oSuRvFCtsAS4SQUPOmUmfW/0dpCa7A==} + '@rspack/binding-linux-x64-gnu@1.0.5': + resolution: {integrity: sha512-qIEMsWOzTKpVm0Sg553gKkua49Kd/sElLD1rZcXjjxjAsD97uq8AiNncArMfYdDKgkKbtwtW/Fb3uVuafTLnZg==} cpu: [x64] os: [linux] @@ -2977,8 +2878,8 @@ packages: cpu: [x64] os: [linux] - '@rspack/binding-linux-x64-musl@1.0.4': - resolution: {integrity: sha512-1Pmuq3qnE45U7uhCJNtRbDiQVF+U4BXbsA+ISNd3Gp/MUZqpuOOgrND9OWw7d+xKRifzEMtd81DaPMkrcXyRvw==} + '@rspack/binding-linux-x64-musl@1.0.5': + resolution: {integrity: sha512-yulltMSQN3aBt3NMURYTmJcpAJBi4eEJ4i9qF0INE8f0885sJpI0j35/31POkCghG1ZOSZkYALFrheKKP9e8pg==} cpu: [x64] os: [linux] @@ -2987,8 +2888,8 @@ packages: cpu: [arm64] os: [win32] - '@rspack/binding-win32-arm64-msvc@1.0.4': - resolution: {integrity: sha512-3tBP4xTAe8XRAlchMj2nlQXy2GOICA5StFK0kQMRId4V3xfgjlKDb/dMHMEHH4R1to1f9er9R0cRydUNP5AnbQ==} + '@rspack/binding-win32-arm64-msvc@1.0.5': + resolution: {integrity: sha512-5oF/qN6TnUj28UAdaOgSIWKq7HG5QgI4p37zvQBBTXZHhrwN2kE6H+TaofWnSqWJynwmGIxJIx8bGo3lDfFbfA==} cpu: [arm64] os: [win32] @@ -2997,8 +2898,8 @@ packages: cpu: [ia32] os: [win32] - '@rspack/binding-win32-ia32-msvc@1.0.4': - resolution: {integrity: sha512-VCXXhOh9aWg31RfvJL87cvqIeL8h+gG2LPkXCJ8kzvQItLg6vlXABCGHf3NlaVUnDtAHnhsAT1sOHiD8G/kMfg==} + '@rspack/binding-win32-ia32-msvc@1.0.5': + resolution: {integrity: sha512-y16IPjd/z6L7+r6RXLu7J/jlZDUenSnJDqo10HnnxtLjOJ+vna+pljI8sHcwu1ao0c3J3uMvbkF34dTiev7Opg==} cpu: [ia32] os: [win32] @@ -3007,16 +2908,16 @@ packages: cpu: [x64] os: [win32] - '@rspack/binding-win32-x64-msvc@1.0.4': - resolution: {integrity: sha512-hlhAZVpL1MmGJUZ730JvOL6zc12BlfIIwRNnn0PkCrNSxNOYknkfKVix8CfPU9r8L2W8MOJfsbtjteCiJmJnQA==} + '@rspack/binding-win32-x64-msvc@1.0.5': + resolution: {integrity: sha512-PSBTbDSgT+ClYvyQTDtWBi/bxXW/xJmVjg9NOWe8KAEl5WNU+pToiCBLLPCGDSa+K7/zr2TDb6QakG/qYItPZw==} cpu: [x64] os: [win32] '@rspack/binding@1.0.3': resolution: {integrity: sha512-wRLUDyi/6jFDDZJIov4uh9H9hJNk7JKDEhaMLM/5lJzzWsTLBB/q6JB1VAdIzOzBhYsU8iIMEVuG3Uih1H43uw==} - '@rspack/binding@1.0.4': - resolution: {integrity: sha512-YbVyVWvYXCAqUqIyBPEwl+M0js4BqVAxqnsRiZG861MXrqNyYbGOMTcc3Pc6D0SW/gkcWugGWzQ5jgMjAIhHzw==} + '@rspack/binding@1.0.5': + resolution: {integrity: sha512-SnVrzRWeKSosJ0/1e5taAeqJ1ISst6NAE1N8YK4ZdUEVWmE26tC2V/yTvZHSsqatc/0Cf+A18IZJx0q6H/DlRw==} '@rspack/core@1.0.3': resolution: {integrity: sha512-BqyBSrcTtsm1EDI10TrK6tEfNsy5vEnVDnbI0HBuQBH1zhKblnvsu6Y2bbS9+OGmB+OPEr76CmuZtzb+7V3wrQ==} @@ -3027,8 +2928,8 @@ packages: '@swc/helpers': optional: true - '@rspack/core@1.0.4': - resolution: {integrity: sha512-/R3JenF5wJSj3DPxiewyIPGzuZV336XpRORjUAOvbHPK6zea8Eeqcx6RopWM6TMikRYdZOHThKV99tyi4QLsMg==} + '@rspack/core@1.0.5': + resolution: {integrity: sha512-UlydS2VupZ6yBx3jCqCHpeEUQNWCrBkTQhPIezK0eCAk13i745byjqXX4tcfN6jR5Kjh/1CIb8r07k9DgGON1w==} engines: {node: '>=16.0.0'} peerDependencies: '@swc/helpers': '>=0.5.1' @@ -3036,6 +2937,11 @@ packages: '@swc/helpers': optional: true + '@rspack/dev-server@1.0.6': + resolution: {integrity: sha512-80IsqqwHHvh1mWioOsRTpx/WF6HahNMC2P6zeVgWVS5lRkz7GRXb0RCFJK7BJuC5QMi0lCCuD7oDV8FUWub93A==} + peerDependencies: + '@rspack/core': '*' + '@rspack/lite-tapable@1.0.0': resolution: {integrity: sha512-7MZf4lburSUZoEenwazwUDKHhqyfnLCGnQ/tKcUtztfmVzfjZfRn/EaiT0AKkYGnL2U8AGsw89oUeVyvaOLVCw==} engines: {node: '>=16.0.0'} @@ -3274,9 +3180,6 @@ packages: resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} engines: {node: '>= 10'} - '@tootallnate/quickjs-emscripten@0.23.0': - resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} - '@trysound/sax@0.2.0': resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==} engines: {node: '>=10.13.0'} @@ -3725,9 +3628,6 @@ packages: '@types/keyv@3.1.4': resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} - '@types/mime-types@2.1.4': - resolution: {integrity: sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w==} - '@types/mime@1.3.5': resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==} @@ -3839,9 +3739,6 @@ packages: '@types/yargs@17.0.32': resolution: {integrity: sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog==} - '@types/yauzl@2.10.3': - resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} - '@vercel/ncc@0.38.1': resolution: {integrity: sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==} hasBin: true @@ -4203,10 +4100,6 @@ packages: assert@2.1.0: resolution: {integrity: sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==} - ast-types@0.13.4: - resolution: {integrity: sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==} - engines: {node: '>=4'} - astral-regex@2.0.0: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} @@ -4227,9 +4120,6 @@ packages: b-validate@1.5.3: resolution: {integrity: sha512-iCvCkGFskbaYtfQ0a3GmcQCHl/Sv1GufXFGuUQ+FE+WJa7A/espLOuFIn09B944V8/ImPj71T4+rTASxO2PAuA==} - b4a@1.6.6: - resolution: {integrity: sha512-5Tk1HLk6b6ctmjIkAcU/Ujv/1WqiDl0F0JdRCR80VsOcUlHcu7pWeWRlOqQLHfDEsVx9YH/aif5AG4ehoCtTmg==} - babel-jest@29.7.0: resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -4298,28 +4188,9 @@ packages: balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - bare-events@2.4.2: - resolution: {integrity: sha512-qMKFd2qG/36aA4GwvKq8MxnPgCQAmBWmSyLWsJcbn8v03wvIPQ/hG1Ms8bPzndZxMDoHpxez5VOS+gC9Yi24/Q==} - - bare-fs@2.3.3: - resolution: {integrity: sha512-7RYKL+vZVCyAsMLi5SPu7QGauGGT8avnP/HO571ndEuV4MYdGXvLhtW67FuLPeEI8EiIY7zbbRR9x7x7HU0kgw==} - - bare-os@2.4.2: - resolution: {integrity: sha512-HZoJwzC+rZ9lqEemTMiO0luOePoGYNBgsLLgegKR/cljiJvcDNhDZQkzC+NC5Oh0aHbdBNSOHpghwMuB5tqhjg==} - - bare-path@2.1.3: - resolution: {integrity: sha512-lh/eITfU8hrj9Ru5quUp0Io1kJWIk1bTjzo7JH1P5dWmQ2EL4hFUlfI8FonAhSlgIfhn63p84CDY/x+PisgcXA==} - - bare-stream@2.2.1: - resolution: {integrity: sha512-YTB47kHwBW9zSG8LD77MIBAAQXjU2WjAkMHeeb7hUplVs6+IoM5I7uEVQNPMB7lj9r8I76UMdoMkGnCodHOLqg==} - base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - basic-ftp@5.0.5: - resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==} - engines: {node: '>=10.0.0'} - batch@0.6.1: resolution: {integrity: sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==} @@ -4420,9 +4291,6 @@ packages: buffer-builder@0.2.0: resolution: {integrity: sha512-7VPMEPuYznPSoR21NE1zvd2Xna6c/CloiZCfcMXR1Jny6PjX0N4Nsa38zcBFo/FMK+BlA+FLKbJCQ0i2yxp+Xg==} - buffer-crc32@0.2.13: - resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} - buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -4569,11 +4437,6 @@ packages: resolution: {integrity: sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==} engines: {node: '>=6.0'} - chromium-bidi@0.6.5: - resolution: {integrity: sha512-RuLrmzYrxSb0s9SgpB+QN5jJucPduZQ/9SIe76MDxYJuecPW5mxMdacJ1f4EtgiV+R0p3sCkznTMvH0MPGFqjA==} - peerDependencies: - devtools-protocol: '*' - ci-info@2.0.0: resolution: {integrity: sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==} @@ -4750,9 +4613,6 @@ packages: commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} - component-emitter@1.3.1: - resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==} - compressible@2.0.18: resolution: {integrity: sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==} engines: {node: '>= 0.6'} @@ -4826,9 +4686,6 @@ packages: resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} engines: {node: '>= 0.6'} - cookiejar@2.1.4: - resolution: {integrity: sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==} - copy-anything@2.0.6: resolution: {integrity: sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==} @@ -5077,10 +4934,6 @@ packages: resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} engines: {node: '>= 12'} - data-uri-to-buffer@6.0.2: - resolution: {integrity: sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==} - engines: {node: '>= 14'} - data-urls@3.0.2: resolution: {integrity: sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==} engines: {node: '>=12'} @@ -5116,23 +4969,6 @@ packages: supports-color: optional: true - debug@3.2.7: - resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - - debug@4.3.1: - resolution: {integrity: sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -5182,9 +5018,6 @@ packages: resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} engines: {node: '>=4.0.0'} - deep-is@0.1.4: - resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} - deepmerge@4.3.1: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} @@ -5222,10 +5055,6 @@ packages: defined@1.0.1: resolution: {integrity: sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q==} - degenerator@5.0.1: - resolution: {integrity: sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==} - engines: {node: '>= 14'} - del@6.1.1: resolution: {integrity: sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg==} engines: {node: '>=10'} @@ -5276,12 +5105,6 @@ packages: detect-node@2.1.0: resolution: {integrity: sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==} - devtools-protocol@0.0.1330662: - resolution: {integrity: sha512-pzh6YQ8zZfz3iKlCvgzVCu22NdpZ8hNmwU6WnQjNVquh0A9iVosPtNLWDwaWVGyrntQlltPFztTMK5Cg6lfCuw==} - - dezalgo@1.0.4: - resolution: {integrity: sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==} - didyoumean@1.2.2: resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==} @@ -5578,10 +5401,6 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} - eventsource@2.0.2: - resolution: {integrity: sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==} - engines: {node: '>=12.0.0'} - evp_bytestokey@1.0.3: resolution: {integrity: sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==} @@ -5616,17 +5435,9 @@ packages: resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} engines: {node: '>=4'} - extract-zip@2.0.1: - resolution: {integrity: sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==} - engines: {node: '>= 10.17.0'} - hasBin: true - fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - fast-fifo@1.3.2: - resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==} - fast-glob@3.3.2: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} engines: {node: '>=8.6.0'} @@ -5660,9 +5471,6 @@ packages: fbjs@3.0.5: resolution: {integrity: sha512-ztsSx77JBtkuMrEypfhgc3cI0+0h+svqeie7xHbh1k/IKdcydnvadp/mUaGgjAOXQmQSxsqgaRhS3q9fy+1kxg==} - fd-slicer@1.1.0: - resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} - fecha@4.2.3: resolution: {integrity: sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==} @@ -5765,9 +5573,6 @@ packages: resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} engines: {node: '>=12.20.0'} - formidable@2.1.2: - resolution: {integrity: sha512-CM3GuJ57US06mlpQ47YcunuUZ9jpm8Vx+P2CGt2j7HpgkKZO/DJYQ0Bobim8G6PFQmK5lOqOOdUXboU+h73A4g==} - forwarded@0.2.0: resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} engines: {node: '>= 0.6'} @@ -5874,10 +5679,6 @@ packages: resolution: {integrity: sha512-g0QYk1dZBxGwk+Ngc+ltRH2IBp2f7zBkBMBJZCDerh6EhlhSR6+9irMCuT/09zD6qkarHUSn529sK/yL4S27mg==} engines: {node: '>= 0.4'} - get-uri@6.0.3: - resolution: {integrity: sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw==} - engines: {node: '>= 14'} - gl-matrix@3.4.3: resolution: {integrity: sha512-wcCp8vu8FT22BnvKVPjXa/ICBWRq/zjFfdofZy1WSpQZpphblv12/bOQLBC1rMM7SGOFS9ltVmKOHil5+Ml7gA==} @@ -6011,10 +5812,6 @@ packages: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true - hexoid@1.0.0: - resolution: {integrity: sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==} - engines: {node: '>=8'} - history@4.10.1: resolution: {integrity: sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==} @@ -6132,10 +5929,6 @@ packages: resolution: {integrity: sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==} engines: {node: '>= 14'} - https-proxy-agent@7.0.5: - resolution: {integrity: sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==} - engines: {node: '>= 14'} - human-signals@2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} @@ -6261,10 +6054,6 @@ packages: invariant@2.2.4: resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==} - ip-address@9.0.5: - resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==} - engines: {node: '>= 12'} - ip-regex@4.3.0: resolution: {integrity: sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==} engines: {node: '>=8'} @@ -6491,9 +6280,6 @@ packages: resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} engines: {node: '>=10'} - is-url@1.2.4: - resolution: {integrity: sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==} - is-weakref@1.0.2: resolution: {integrity: sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==} @@ -6515,10 +6301,6 @@ packages: is-yarn-global@0.3.0: resolution: {integrity: sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==} - is2@2.0.9: - resolution: {integrity: sha512-rZkHeBn9Zzq52sd9IUIV3a5mfwBY+o2HePMh0wkGBM4z4qjvy2GwVxQ6nNXSfw6MmVP6gf1QIlWjiOavhM3x5g==} - engines: {node: '>=v0.10.0'} - isarray@0.0.1: resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} @@ -6739,9 +6521,6 @@ packages: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true - jsbn@1.1.0: - resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==} - jsdom@20.0.3: resolution: {integrity: sha512-SYhBvTh89tTfCD/CRdSOm13mOBa42iTaTyfyEWBdKcGdPxPtLFBXuHR8XHb33YNYaP+lLbmSvBTsnoesCNJEsQ==} engines: {node: '>=14'} @@ -7004,10 +6783,6 @@ packages: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} - lru-cache@7.18.3: - resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==} - engines: {node: '>=12'} - magic-string@0.30.11: resolution: {integrity: sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A==} @@ -7115,11 +6890,6 @@ packages: engines: {node: '>=4'} hasBin: true - mime@2.6.0: - resolution: {integrity: sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==} - engines: {node: '>=4.0.0'} - hasBin: true - mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -7173,9 +6943,6 @@ packages: resolution: {integrity: sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA==} engines: {node: '>=4.0.0'} - mitt@3.0.1: - resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} - mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true @@ -7258,10 +7025,6 @@ packages: neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} - netmask@2.0.2: - resolution: {integrity: sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==} - engines: {node: '>= 0.4.0'} - next-tick@1.1.0: resolution: {integrity: sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==} @@ -7482,14 +7245,6 @@ packages: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} - pac-proxy-agent@7.0.2: - resolution: {integrity: sha512-BFi3vZnO9X5Qt6NRz7ZOaPja3ic0PhlsmCRYLOpN11+mWBCR6XJDqW5RF3j8jm4WGGQZtBA+bTfxYzeKW73eHg==} - engines: {node: '>= 14'} - - pac-resolver@7.0.1: - resolution: {integrity: sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==} - engines: {node: '>= 14'} - package-json@6.5.0: resolution: {integrity: sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==} engines: {node: '>=8'} @@ -7617,9 +7372,6 @@ packages: pdfast@0.2.0: resolution: {integrity: sha512-cq6TTu6qKSFUHwEahi68k/kqN2mfepjkGrG9Un70cgdRRKLKY6Rf8P8uvP2NvZktaQZNF3YE7agEkLj0vGK9bA==} - pend@1.2.0: - resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} - picocolors@1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} @@ -7824,10 +7576,6 @@ packages: resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} engines: {node: '>= 0.6.0'} - progress@2.0.3: - resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} - engines: {node: '>=0.4.0'} - promise-inflight@1.0.1: resolution: {integrity: sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==} peerDependencies: @@ -7853,13 +7601,6 @@ packages: resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} engines: {node: '>= 0.10'} - proxy-agent@6.4.0: - resolution: {integrity: sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==} - engines: {node: '>= 14'} - - proxy-from-env@1.1.0: - resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - prr@1.0.1: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} @@ -7935,15 +7676,6 @@ packages: resolution: {integrity: sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==} engines: {node: '>=8'} - puppeteer-core@23.3.0: - resolution: {integrity: sha512-sB2SsVMFs4gKad5OCdv6w5vocvtEUrRl0zQqSyRPbo/cj1Ktbarmhxy02Zyb9R9HrssBcJDZbkrvBnbaesPyYg==} - engines: {node: '>=18'} - - puppeteer@23.3.0: - resolution: {integrity: sha512-e2jY8cdWSUGsrLxqGm3hIbJq/UIk1uOY8XY7SM51leXkH7shrIyE91lK90Q9byX6tte+cyL3HKqlWBEd6TjWTA==} - engines: {node: '>=18'} - hasBin: true - pure-rand@6.1.0: resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==} @@ -7973,9 +7705,6 @@ packages: queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - queue-tick@1.0.1: - resolution: {integrity: sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==} - quick-lru@4.0.1: resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==} engines: {node: '>=8'} @@ -8752,28 +8481,12 @@ packages: resolution: {integrity: sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg==} engines: {node: '>=18'} - smart-buffer@4.2.0: - resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} - engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} - snake-case@3.0.4: resolution: {integrity: sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==} - sockjs-client@1.6.1: - resolution: {integrity: sha512-2g0tjOR+fRs0amxENLi/q5TiJTqY+WXFOzb5UwXndlK6TO3U/mirZznpx6w34HVMoc3g7cY24yC/ZMIYnDlfkw==} - engines: {node: '>=12'} - sockjs@0.3.24: resolution: {integrity: sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==} - socks-proxy-agent@8.0.4: - resolution: {integrity: sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw==} - engines: {node: '>= 14'} - - socks@2.8.3: - resolution: {integrity: sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==} - engines: {node: '>= 10.0.0', npm: '>= 3.0.0'} - sort-keys@4.2.0: resolution: {integrity: sha512-aUYIEU/UviqPgc8mHR6IW1EGxkAXpeRETYcrzg8cLAvUPZcpAlleSXHV2mY7G12GphSH6Gzv+4MMVSSkbdteHg==} engines: {node: '>=8'} @@ -8836,9 +8549,6 @@ packages: sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} - sprintf-js@1.1.3: - resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==} - ssri@6.0.2: resolution: {integrity: sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==} @@ -8884,9 +8594,6 @@ packages: stream-shift@1.0.3: resolution: {integrity: sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==} - streamx@2.20.0: - resolution: {integrity: sha512-ZGd1LhDeGFucr1CUCTBOS58ZhEendd0ttpGT3usTvosS4ntIwKN9LJFp+OeCSprsCPL14BXVRZlHGRY1V9PVzQ==} - strict-uri-encode@2.0.0: resolution: {integrity: sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==} engines: {node: '>=4'} @@ -8982,19 +8689,10 @@ packages: engines: {node: '>=16 || 14 >=14.17'} hasBin: true - superagent@8.1.2: - resolution: {integrity: sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==} - engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net - superstruct@1.0.4: resolution: {integrity: sha512-7JpaAoX2NGyoFlI9NBh66BQXGONc+uE+MRS5i2iOBKuS4e+ccgMDjATgZldkah+33DakBxDHiss9kvUcGAO8UQ==} engines: {node: '>=14.0.0'} - supertest@6.3.4: - resolution: {integrity: sha512-erY3HFDG0dPnhw4U+udPfrzXa4xhSG+n4rxfRuZWCUvjFWwKl+OxWf/7zk50s84/fAAs7vf5QAb9uRa0cCykxw==} - engines: {node: '>=6.4.0'} - supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} engines: {node: '>=0.8.0'} @@ -9049,15 +8747,6 @@ packages: resolution: {integrity: sha512-KCuXjYxCZ3ru40dmND+oCLsXyuA8hoseu2SS404Px5ouyS0A99v8X/mdiLqsR5MTAyamMBN7PRwt2Dv3+xGIxw==} hasBin: true - tar-fs@3.0.6: - resolution: {integrity: sha512-iokBDQQkUyeXhgPYaZxmczGPhnhXZ0CmrqI+MOb/WFGS9DW5wnfrLgtjUJBvz50vQ3qfRwJ62QVoCFu8mPVu5w==} - - tar-stream@3.1.7: - resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==} - - tcp-port-used@1.0.2: - resolution: {integrity: sha512-l7ar8lLUD3XS1V2lfoJlCBaeoaWo/2xfYt81hM7VlvR4RrMVFqfmzfhLVk40hAb368uitje5gPtBRL1m/DGvLA==} - terser-webpack-plugin@5.3.10: resolution: {integrity: sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==} engines: {node: '>= 10.13.0'} @@ -9088,9 +8777,6 @@ packages: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} - text-decoder@1.1.1: - resolution: {integrity: sha512-8zll7REEv4GDD3x4/0pW+ppIxSNs7H1J10IKFZsuOMscumCdM2a+toDGLPA3T+1+fLBql4zbt5z83GEQGGV5VA==} - thenify-all@1.6.0: resolution: {integrity: sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==} engines: {node: '>=0.8'} @@ -9305,9 +8991,6 @@ packages: resolution: {integrity: sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==} engines: {node: '>= 0.4'} - typed-query-selector@2.12.0: - resolution: {integrity: sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==} - typedarray-to-buffer@3.1.5: resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==} @@ -9343,9 +9026,6 @@ packages: unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} - unbzip2-stream@1.4.3: - resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==} - undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} @@ -9424,9 +9104,6 @@ packages: url@0.11.3: resolution: {integrity: sha512-6hxOLGfZASQK/cijlZnZJTq8OXAkt/3YGfQX45vvMYXpZoo8NdWZcY73K108Jf759lS1Bv/8wXnHDTSz17dSRw==} - urlpattern-polyfill@10.0.0: - resolution: {integrity: sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==} - use-callback-ref@1.3.2: resolution: {integrity: sha512-elOQwe6Q8gqZgDA8mrh44qRTQqpIHDcZ3hXTLjBe1i4ph8XpNJnO+aQf3NaG+lriLopI4HMx9VjQLfPQ6vhnoA==} engines: {node: '>=10'} @@ -9536,9 +9213,6 @@ packages: wabt@1.0.0-nightly.20180421: resolution: {integrity: sha512-bsu9zk672KACjoabONcAS94IS20prRm05IbiIUGfa8eBpRLjWZv8ugocdinV/ONh0mFMfXrVWkvF1/BNtwIfUw==} - wait-for-expect@3.0.2: - resolution: {integrity: sha512-cfS1+DZxuav1aBYbaO/kE06EOS8yRw7qOFoD3XtjTkYvCvh3zUvNST8DXK/nPaeqIzIv3P3kL3lRJn8iwOiSag==} - walker@1.0.8: resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} @@ -9858,16 +9532,9 @@ packages: resolution: {integrity: sha512-1/9UrdHjDZc0eOU0HxOHoS78C69UD3JRMvzlJ7S79S2nTaWRA/whGCTV8o9e/N/1Va9YIV7Q4sOxD8VV4pCWOw==} engines: {node: '>=12'} - yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} - yargs@3.10.0: resolution: {integrity: sha512-QFzUah88GAGy9lyDKGBqZdkYApt63rCXYBGYnEP4xDJPXNqXXnBDACnbrXnViV6jRSqAePwrATi2i8mfYm4L1A==} - yauzl@2.10.0: - resolution: {integrity: sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==} - yn@3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} engines: {node: '>=6'} @@ -11992,19 +11659,6 @@ snapshots: '@prefresh/utils@1.2.0': {} - '@puppeteer/browsers@2.4.0': - dependencies: - debug: 4.3.6 - extract-zip: 2.0.1 - progress: 2.0.3 - proxy-agent: 6.4.0 - semver: 7.6.3 - tar-fs: 3.0.6 - unbzip2-stream: 1.4.3 - yargs: 17.7.2 - transitivePeerDependencies: - - supports-color - '@rollup/rollup-android-arm-eabi@4.17.2': optional: true @@ -12074,55 +11728,55 @@ snapshots: '@rspack/binding-darwin-arm64@1.0.3': optional: true - '@rspack/binding-darwin-arm64@1.0.4': + '@rspack/binding-darwin-arm64@1.0.5': optional: true '@rspack/binding-darwin-x64@1.0.3': optional: true - '@rspack/binding-darwin-x64@1.0.4': + '@rspack/binding-darwin-x64@1.0.5': optional: true '@rspack/binding-linux-arm64-gnu@1.0.3': optional: true - '@rspack/binding-linux-arm64-gnu@1.0.4': + '@rspack/binding-linux-arm64-gnu@1.0.5': optional: true '@rspack/binding-linux-arm64-musl@1.0.3': optional: true - '@rspack/binding-linux-arm64-musl@1.0.4': + '@rspack/binding-linux-arm64-musl@1.0.5': optional: true '@rspack/binding-linux-x64-gnu@1.0.3': optional: true - '@rspack/binding-linux-x64-gnu@1.0.4': + '@rspack/binding-linux-x64-gnu@1.0.5': optional: true '@rspack/binding-linux-x64-musl@1.0.3': optional: true - '@rspack/binding-linux-x64-musl@1.0.4': + '@rspack/binding-linux-x64-musl@1.0.5': optional: true '@rspack/binding-win32-arm64-msvc@1.0.3': optional: true - '@rspack/binding-win32-arm64-msvc@1.0.4': + '@rspack/binding-win32-arm64-msvc@1.0.5': optional: true '@rspack/binding-win32-ia32-msvc@1.0.3': optional: true - '@rspack/binding-win32-ia32-msvc@1.0.4': + '@rspack/binding-win32-ia32-msvc@1.0.5': optional: true '@rspack/binding-win32-x64-msvc@1.0.3': optional: true - '@rspack/binding-win32-x64-msvc@1.0.4': + '@rspack/binding-win32-x64-msvc@1.0.5': optional: true '@rspack/binding@1.0.3': @@ -12137,17 +11791,17 @@ snapshots: '@rspack/binding-win32-ia32-msvc': 1.0.3 '@rspack/binding-win32-x64-msvc': 1.0.3 - '@rspack/binding@1.0.4': + '@rspack/binding@1.0.5': optionalDependencies: - '@rspack/binding-darwin-arm64': 1.0.4 - '@rspack/binding-darwin-x64': 1.0.4 - '@rspack/binding-linux-arm64-gnu': 1.0.4 - '@rspack/binding-linux-arm64-musl': 1.0.4 - '@rspack/binding-linux-x64-gnu': 1.0.4 - '@rspack/binding-linux-x64-musl': 1.0.4 - '@rspack/binding-win32-arm64-msvc': 1.0.4 - '@rspack/binding-win32-ia32-msvc': 1.0.4 - '@rspack/binding-win32-x64-msvc': 1.0.4 + '@rspack/binding-darwin-arm64': 1.0.5 + '@rspack/binding-darwin-x64': 1.0.5 + '@rspack/binding-linux-arm64-gnu': 1.0.5 + '@rspack/binding-linux-arm64-musl': 1.0.5 + '@rspack/binding-linux-x64-gnu': 1.0.5 + '@rspack/binding-linux-x64-musl': 1.0.5 + '@rspack/binding-win32-arm64-msvc': 1.0.5 + '@rspack/binding-win32-ia32-msvc': 1.0.5 + '@rspack/binding-win32-x64-msvc': 1.0.5 optional: true '@rspack/core@1.0.3(@swc/helpers@0.5.12)': @@ -12159,14 +11813,56 @@ snapshots: optionalDependencies: '@swc/helpers': 0.5.12 - '@rspack/core@1.0.4': + '@rspack/core@1.0.5': dependencies: '@module-federation/runtime-tools': 0.5.1 - '@rspack/binding': 1.0.4 + '@rspack/binding': 1.0.5 '@rspack/lite-tapable': 1.0.0 caniuse-lite: 1.0.30001660 optional: true + '@rspack/dev-server@1.0.6(@rspack/core@packages+rspack)(@types/express@4.17.21)(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0)))': + dependencies: + '@rspack/core': link:packages/rspack + chokidar: 3.6.0 + connect-history-api-fallback: 2.0.0 + express: 4.19.2 + http-proxy-middleware: 2.0.6(@types/express@4.17.21) + mime-types: 2.1.35 + p-retry: 4.6.2 + webpack-dev-middleware: 7.4.2(webpack@5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0))) + webpack-dev-server: 5.0.4(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0))) + ws: 8.18.0 + transitivePeerDependencies: + - '@types/express' + - bufferutil + - debug + - supports-color + - utf-8-validate + - webpack + - webpack-cli + + '@rspack/dev-server@1.0.6(@rspack/core@packages+rspack)(@types/express@4.17.21)(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0)))': + dependencies: + '@rspack/core': link:packages/rspack + chokidar: 3.6.0 + connect-history-api-fallback: 2.0.0 + express: 4.19.2 + http-proxy-middleware: 2.0.6(@types/express@4.17.21) + mime-types: 2.1.35 + p-retry: 4.6.2 + webpack-dev-middleware: 7.4.2(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0))) + webpack-dev-server: 5.0.4(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.94.0(webpack-cli@5.1.4(webpack@5.94.0))) + ws: 8.18.0 + transitivePeerDependencies: + - '@types/express' + - bufferutil + - debug + - supports-color + - utf-8-validate + - webpack + - webpack-cli + '@rspack/lite-tapable@1.0.0': {} '@rspack/plugin-preact-refresh@1.0.0(@prefresh/core@1.5.2(preact@10.23.2))(@prefresh/utils@1.2.0)': @@ -12443,8 +12139,6 @@ snapshots: '@tootallnate/once@2.0.0': {} - '@tootallnate/quickjs-emscripten@0.23.0': {} - '@trysound/sax@0.2.0': {} '@tsconfig/node10@1.0.11': {} @@ -13422,8 +13116,6 @@ snapshots: dependencies: '@types/node': 20.12.7 - '@types/mime-types@2.1.4': {} - '@types/mime@1.3.5': {} '@types/minimatch@5.1.2': {} @@ -13565,11 +13257,6 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@types/yauzl@2.10.3': - dependencies: - '@types/node': 20.12.7 - optional: true - '@vercel/ncc@0.38.1': {} '@vue/compiler-core@3.4.21': @@ -13962,10 +13649,6 @@ snapshots: object.assign: 4.1.5 util: 0.12.5 - ast-types@0.13.4: - dependencies: - tslib: 2.6.2 - astral-regex@2.0.0: {} asynckit@0.4.0: {} @@ -13984,8 +13667,6 @@ snapshots: b-validate@1.5.3: {} - b4a@1.6.6: {} - babel-jest@29.7.0(@babel/core@7.24.4): dependencies: '@babel/core': 7.24.4 @@ -14108,34 +13789,8 @@ snapshots: balanced-match@1.0.2: {} - bare-events@2.4.2: - optional: true - - bare-fs@2.3.3: - dependencies: - bare-events: 2.4.2 - bare-path: 2.1.3 - bare-stream: 2.2.1 - optional: true - - bare-os@2.4.2: - optional: true - - bare-path@2.1.3: - dependencies: - bare-os: 2.4.2 - optional: true - - bare-stream@2.2.1: - dependencies: - b4a: 1.6.6 - streamx: 2.20.0 - optional: true - base64-js@1.5.1: {} - basic-ftp@5.0.5: {} - batch@0.6.1: {} before-after-hook@2.2.3: {} @@ -14306,8 +13961,6 @@ snapshots: buffer-builder@0.2.0: {} - buffer-crc32@0.2.13: {} - buffer-from@1.1.2: {} buffer-xor@1.0.3: {} @@ -14497,13 +14150,6 @@ snapshots: chrome-trace-event@1.0.3: {} - chromium-bidi@0.6.5(devtools-protocol@0.0.1330662): - dependencies: - devtools-protocol: 0.0.1330662 - mitt: 3.0.1 - urlpattern-polyfill: 10.0.0 - zod: 3.23.8 - ci-info@2.0.0: {} ci-info@3.9.0: {} @@ -14669,8 +14315,6 @@ snapshots: commondir@1.0.1: {} - component-emitter@1.3.1: {} - compressible@2.0.18: dependencies: mime-db: 1.52.0 @@ -14757,8 +14401,6 @@ snapshots: cookie@0.6.0: {} - cookiejar@2.1.4: {} - copy-anything@2.0.6: dependencies: is-what: 3.14.1 @@ -14943,7 +14585,7 @@ snapshots: semver: 7.6.2 webpack: 5.94.0(@swc/core@1.4.0(@swc/helpers@0.5.1))(webpack-cli@5.1.4(webpack@5.94.0)) - css-loader@6.11.0(@rspack/core@1.0.4)(webpack@5.94.0(webpack-cli@5.1.4)): + css-loader@6.11.0(@rspack/core@1.0.5)(webpack@5.94.0(webpack-cli@5.1.4)): dependencies: icss-utils: 5.1.0(postcss@8.4.38) postcss: 8.4.38 @@ -14954,7 +14596,7 @@ snapshots: postcss-value-parser: 4.2.0 semver: 7.6.0 optionalDependencies: - '@rspack/core': 1.0.4 + '@rspack/core': 1.0.5 webpack: 5.94.0(webpack-cli@5.1.4) css-loader@6.11.0(@rspack/core@packages+rspack)(webpack@5.94.0(@swc/core@1.4.0(@swc/helpers@0.5.8))(webpack-cli@5.1.4(webpack@5.94.0))): @@ -15128,8 +14770,6 @@ snapshots: data-uri-to-buffer@4.0.1: {} - data-uri-to-buffer@6.0.2: {} - data-urls@3.0.2: dependencies: abab: 2.0.6 @@ -15169,14 +14809,6 @@ snapshots: dependencies: ms: 2.0.0 - debug@3.2.7: - dependencies: - ms: 2.1.3 - - debug@4.3.1: - dependencies: - ms: 2.1.2 - debug@4.3.4: dependencies: ms: 2.1.2 @@ -15208,8 +14840,6 @@ snapshots: deep-extend@0.6.0: {} - deep-is@0.1.4: {} - deepmerge@4.3.1: {} default-browser-id@5.0.0: {} @@ -15245,12 +14875,6 @@ snapshots: defined@1.0.1: {} - degenerator@5.0.1: - dependencies: - ast-types: 0.13.4 - escodegen: 2.1.0 - esprima: 4.0.1 - del@6.1.1: dependencies: globby: 11.1.0 @@ -15291,13 +14915,6 @@ snapshots: detect-node@2.1.0: {} - devtools-protocol@0.0.1330662: {} - - dezalgo@1.0.4: - dependencies: - asap: 2.0.6 - wrappy: 1.0.2 - didyoumean@1.2.2: {} diff-sequences@29.6.3: {} @@ -15641,8 +15258,6 @@ snapshots: events@3.3.0: {} - eventsource@2.0.2: {} - evp_bytestokey@1.0.3: dependencies: md5.js: 1.3.5 @@ -15730,20 +15345,8 @@ snapshots: iconv-lite: 0.4.24 tmp: 0.0.33 - extract-zip@2.0.1: - dependencies: - debug: 4.3.6 - get-stream: 5.2.0 - yauzl: 2.10.0 - optionalDependencies: - '@types/yauzl': 2.10.3 - transitivePeerDependencies: - - supports-color - fast-deep-equal@3.1.3: {} - fast-fifo@1.3.2: {} - fast-glob@3.3.2: dependencies: '@nodelib/fs.stat': 2.0.5 @@ -15788,10 +15391,6 @@ snapshots: transitivePeerDependencies: - encoding - fd-slicer@1.1.0: - dependencies: - pend: 1.2.0 - fecha@4.2.3: {} fetch-blob@3.2.0: @@ -15914,13 +15513,6 @@ snapshots: dependencies: fetch-blob: 3.2.0 - formidable@2.1.2: - dependencies: - dezalgo: 1.0.4 - hexoid: 1.0.0 - once: 1.4.0 - qs: 6.12.0 - forwarded@0.2.0: {} fresh@0.5.2: {} @@ -16029,15 +15621,6 @@ snapshots: es-errors: 1.3.0 get-intrinsic: 1.2.4 - get-uri@6.0.3: - dependencies: - basic-ftp: 5.0.5 - data-uri-to-buffer: 6.0.2 - debug: 4.3.6 - fs-extra: 11.2.0 - transitivePeerDependencies: - - supports-color - gl-matrix@3.4.3: {} glob-parent@3.1.0: @@ -16193,8 +15776,6 @@ snapshots: he@1.2.0: {} - hexoid@1.0.0: {} - history@4.10.1: dependencies: '@babel/runtime': 7.24.4 @@ -16376,13 +15957,6 @@ snapshots: transitivePeerDependencies: - supports-color - https-proxy-agent@7.0.5: - dependencies: - agent-base: 7.1.1 - debug: 4.3.6 - transitivePeerDependencies: - - supports-color - human-signals@2.1.0: {} human-signals@5.0.0: {} @@ -16493,11 +16067,6 @@ snapshots: dependencies: loose-envify: 1.4.0 - ip-address@9.0.5: - dependencies: - jsbn: 1.1.0 - sprintf-js: 1.1.3 - ip-regex@4.3.0: {} ipaddr.js@1.9.1: {} @@ -16675,8 +16244,6 @@ snapshots: is-unicode-supported@0.1.0: {} - is-url@1.2.4: {} - is-weakref@1.0.2: dependencies: call-bind: 1.0.7 @@ -16695,12 +16262,6 @@ snapshots: is-yarn-global@0.3.0: {} - is2@2.0.9: - dependencies: - deep-is: 0.1.4 - ip-regex: 4.3.0 - is-url: 1.2.4 - isarray@0.0.1: {} isarray@1.0.0: {} @@ -17124,8 +16685,6 @@ snapshots: dependencies: argparse: 2.0.1 - jsbn@1.1.0: {} - jsdom@20.0.3: dependencies: abab: 2.0.6 @@ -17441,8 +17000,6 @@ snapshots: dependencies: yallist: 4.0.0 - lru-cache@7.18.3: {} - magic-string@0.30.11: dependencies: '@jridgewell/sourcemap-codec': 1.5.0 @@ -17535,8 +17092,6 @@ snapshots: mime@1.6.0: {} - mime@2.6.0: {} - mimic-fn@2.1.0: {} mimic-fn@3.1.0: {} @@ -17586,8 +17141,6 @@ snapshots: stream-each: 1.2.3 through2: 2.0.5 - mitt@3.0.1: {} - mkdirp@0.5.6: dependencies: minimist: 1.2.8 @@ -17669,8 +17222,6 @@ snapshots: neo-async@2.6.2: {} - netmask@2.0.2: {} - next-tick@1.1.0: {} no-case@3.0.4: @@ -17892,24 +17443,6 @@ snapshots: p-try@2.2.0: {} - pac-proxy-agent@7.0.2: - dependencies: - '@tootallnate/quickjs-emscripten': 0.23.0 - agent-base: 7.1.1 - debug: 4.3.6 - get-uri: 6.0.3 - http-proxy-agent: 7.0.2 - https-proxy-agent: 7.0.5 - pac-resolver: 7.0.1 - socks-proxy-agent: 8.0.4 - transitivePeerDependencies: - - supports-color - - pac-resolver@7.0.1: - dependencies: - degenerator: 5.0.1 - netmask: 2.0.2 - package-json@6.5.0: dependencies: got: 9.6.0 @@ -18030,8 +17563,6 @@ snapshots: pdfast@0.2.0: {} - pend@1.2.0: {} - picocolors@1.0.0: {} picocolors@1.0.1: {} @@ -18219,8 +17750,6 @@ snapshots: process@0.11.10: {} - progress@2.0.3: {} - promise-inflight@1.0.1(bluebird@3.7.2): optionalDependencies: bluebird: 3.7.2 @@ -18247,21 +17776,6 @@ snapshots: forwarded: 0.2.0 ipaddr.js: 1.9.1 - proxy-agent@6.4.0: - dependencies: - agent-base: 7.1.1 - debug: 4.3.6 - http-proxy-agent: 7.0.2 - https-proxy-agent: 7.0.4 - lru-cache: 7.18.3 - pac-proxy-agent: 7.0.2 - proxy-from-env: 1.1.0 - socks-proxy-agent: 8.0.4 - transitivePeerDependencies: - - supports-color - - proxy-from-env@1.1.0: {} - prr@1.0.1: optional: true @@ -18380,33 +17894,6 @@ snapshots: dependencies: escape-goat: 2.1.1 - puppeteer-core@23.3.0: - dependencies: - '@puppeteer/browsers': 2.4.0 - chromium-bidi: 0.6.5(devtools-protocol@0.0.1330662) - debug: 4.3.6 - devtools-protocol: 0.0.1330662 - typed-query-selector: 2.12.0 - ws: 8.18.0 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - - puppeteer@23.3.0(typescript@5.0.2): - dependencies: - '@puppeteer/browsers': 2.4.0 - chromium-bidi: 0.6.5(devtools-protocol@0.0.1330662) - cosmiconfig: 9.0.0(typescript@5.0.2) - devtools-protocol: 0.0.1330662 - puppeteer-core: 23.3.0 - typed-query-selector: 2.12.0 - transitivePeerDependencies: - - bufferutil - - supports-color - - typescript - - utf-8-validate - pure-rand@6.1.0: {} qs@6.11.0: @@ -18432,8 +17919,6 @@ snapshots: queue-microtask@1.2.3: {} - queue-tick@1.0.1: {} - quick-lru@4.0.1: {} quickselect@1.1.1: {} @@ -19282,42 +18767,17 @@ snapshots: ansi-styles: 6.2.1 is-fullwidth-code-point: 5.0.0 - smart-buffer@4.2.0: {} - snake-case@3.0.4: dependencies: dot-case: 3.0.4 tslib: 2.6.2 - sockjs-client@1.6.1: - dependencies: - debug: 3.2.7 - eventsource: 2.0.2 - faye-websocket: 0.11.4 - inherits: 2.0.4 - url-parse: 1.5.10 - transitivePeerDependencies: - - supports-color - sockjs@0.3.24: dependencies: faye-websocket: 0.11.4 uuid: 8.3.2 websocket-driver: 0.7.4 - socks-proxy-agent@8.0.4: - dependencies: - agent-base: 7.1.1 - debug: 4.3.6 - socks: 2.8.3 - transitivePeerDependencies: - - supports-color - - socks@2.8.3: - dependencies: - ip-address: 9.0.5 - smart-buffer: 4.2.0 - sort-keys@4.2.0: dependencies: is-plain-obj: 2.1.0 @@ -19389,8 +18849,6 @@ snapshots: sprintf-js@1.0.3: {} - sprintf-js@1.1.3: {} - ssri@6.0.2: dependencies: figgy-pudding: 3.5.2 @@ -19441,14 +18899,6 @@ snapshots: stream-shift@1.0.3: {} - streamx@2.20.0: - dependencies: - fast-fifo: 1.3.2 - queue-tick: 1.0.1 - text-decoder: 1.1.1 - optionalDependencies: - bare-events: 2.4.2 - strict-uri-encode@2.0.0: {} string-argv@0.3.2: {} @@ -19558,30 +19008,8 @@ snapshots: pirates: 4.0.6 ts-interface-checker: 0.1.13 - superagent@8.1.2: - dependencies: - component-emitter: 1.3.1 - cookiejar: 2.1.4 - debug: 4.3.6 - fast-safe-stringify: 2.1.1 - form-data: 4.0.0 - formidable: 2.1.2 - methods: 1.1.2 - mime: 2.6.0 - qs: 6.12.0 - semver: 7.6.3 - transitivePeerDependencies: - - supports-color - superstruct@1.0.4: {} - supertest@6.3.4: - dependencies: - methods: 1.1.2 - superagent: 8.1.2 - transitivePeerDependencies: - - supports-color - supports-color@2.0.0: {} supports-color@5.5.0: @@ -19674,27 +19102,6 @@ snapshots: resolve: 1.22.8 string.prototype.trim: 1.2.9 - tar-fs@3.0.6: - dependencies: - pump: 3.0.0 - tar-stream: 3.1.7 - optionalDependencies: - bare-fs: 2.3.3 - bare-path: 2.1.3 - - tar-stream@3.1.7: - dependencies: - b4a: 1.6.6 - fast-fifo: 1.3.2 - streamx: 2.20.0 - - tcp-port-used@1.0.2: - dependencies: - debug: 4.3.1 - is2: 2.0.9 - transitivePeerDependencies: - - supports-color - terser-webpack-plugin@5.3.10(@swc/core@1.4.0(@swc/helpers@0.5.1))(webpack@5.94.0(@swc/core@1.4.0(@swc/helpers@0.5.1))(webpack-cli@5.1.4(webpack@5.94.0))): dependencies: '@jridgewell/trace-mapping': 0.3.25 @@ -19777,10 +19184,6 @@ snapshots: glob: 7.2.3 minimatch: 3.1.2 - text-decoder@1.1.1: - dependencies: - b4a: 1.6.6 - thenify-all@1.6.0: dependencies: thenify: 3.3.1 @@ -20041,8 +19444,6 @@ snapshots: is-typed-array: 1.1.13 possible-typed-array-names: 1.0.0 - typed-query-selector@2.12.0: {} - typedarray-to-buffer@3.1.5: dependencies: is-typedarray: 1.0.0 @@ -20074,11 +19475,6 @@ snapshots: has-symbols: 1.0.3 which-boxed-primitive: 1.0.2 - unbzip2-stream@1.4.3: - dependencies: - buffer: 5.7.1 - through: 2.3.8 - undici-types@5.26.5: {} undici@5.28.4: @@ -20164,8 +19560,6 @@ snapshots: punycode: 1.4.1 qs: 6.12.0 - urlpattern-polyfill@10.0.0: {} - use-callback-ref@1.3.2(@types/react@18.2.75)(react@18.3.1): dependencies: react: 18.3.1 @@ -20285,8 +19679,6 @@ snapshots: wabt@1.0.0-nightly.20180421: {} - wait-for-expect@3.0.2: {} - walker@1.0.8: dependencies: makeerror: 1.0.12 @@ -20354,6 +19746,17 @@ snapshots: webpack: 5.94.0(webpack-cli@5.1.4) webpack-merge: 5.9.0 + webpack-dev-middleware@7.4.2(webpack@5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0))): + dependencies: + colorette: 2.0.19 + memfs: 4.8.1 + mime-types: 2.1.35 + on-finished: 2.4.1 + range-parser: 1.2.1 + schema-utils: 4.2.0 + optionalDependencies: + webpack: 5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0)) + webpack-dev-middleware@7.4.2(webpack@5.94.0(@swc/core@1.4.0(@swc/helpers@0.5.1))(webpack-cli@5.1.4(webpack@5.94.0))): dependencies: colorette: 2.0.19 @@ -20387,6 +19790,47 @@ snapshots: optionalDependencies: webpack: 5.94.0(webpack-cli@5.1.4(webpack@5.94.0)) + webpack-dev-server@5.0.4(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0))): + dependencies: + '@types/bonjour': 3.5.13 + '@types/connect-history-api-fallback': 1.5.4 + '@types/express': 4.17.21 + '@types/serve-index': 1.9.4 + '@types/serve-static': 1.15.7 + '@types/sockjs': 0.3.36 + '@types/ws': 8.5.10 + ansi-html-community: 0.0.8 + bonjour-service: 1.2.1 + chokidar: 3.6.0 + colorette: 2.0.19 + compression: 1.7.4 + connect-history-api-fallback: 2.0.0 + default-gateway: 6.0.3 + express: 4.19.2 + graceful-fs: 4.2.10(patch_hash=ivtm2a2cfr5pomcfbedhmr5v2q) + html-entities: 2.5.2 + http-proxy-middleware: 2.0.6(@types/express@4.17.21) + ipaddr.js: 2.1.0 + launch-editor: 2.6.1 + open: 10.1.0 + p-retry: 6.2.0 + rimraf: 5.0.9 + schema-utils: 4.2.0 + selfsigned: 2.4.1 + serve-index: 1.9.1 + sockjs: 0.3.24 + spdy: 4.0.2 + webpack-dev-middleware: 7.4.2(webpack@5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0))) + ws: 8.17.1 + optionalDependencies: + webpack: 5.92.0(@swc/core@1.4.0)(webpack-cli@5.1.4(webpack@5.94.0)) + webpack-cli: 5.1.4(webpack@5.94.0) + transitivePeerDependencies: + - bufferutil + - debug + - supports-color + - utf-8-validate + webpack-dev-server@5.0.4(webpack-cli@5.1.4(webpack@5.94.0))(webpack@5.94.0(@swc/core@1.4.0(@swc/helpers@0.5.1))(webpack-cli@5.1.4(webpack@5.94.0))): dependencies: '@types/bonjour': 3.5.13 @@ -20894,16 +20338,6 @@ snapshots: y18n: 5.0.8 yargs-parser: 21.1.1 - yargs@17.7.2: - dependencies: - cliui: 8.0.1 - escalade: 3.1.2 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 - y18n: 5.0.8 - yargs-parser: 21.1.1 - yargs@3.10.0: dependencies: camelcase: 1.2.1 @@ -20911,11 +20345,6 @@ snapshots: decamelize: 1.2.0 window-size: 0.1.0 - yauzl@2.10.0: - dependencies: - buffer-crc32: 0.2.13 - fd-slicer: 1.1.0 - yn@3.1.1: {} yocto-queue@0.1.0: {} diff --git a/website/docs/en/config/dev-server.mdx b/website/docs/en/config/dev-server.mdx index 5f1429ac526..831368b44c9 100644 --- a/website/docs/en/config/dev-server.mdx +++ b/website/docs/en/config/dev-server.mdx @@ -4,7 +4,7 @@ import WebpackLicense from '@components/WebpackLicense'; # DevServer -This page describes the options that affect the behavior of `@rspack/dev-server` (short: dev-server), based on `webpack-dev-server@5`,which facilitates rapid application development. +This page describes the options that affect the behavior of [`@rspack/dev-server`](https://github.com/web-infra-dev/rspack-dev-server) (short: dev-server), based on `webpack-dev-server@5`,which facilitates rapid application development. - **Type:** `object` diff --git a/website/docs/en/config/index.mdx b/website/docs/en/config/index.mdx index d254eb55630..25522a5562d 100644 --- a/website/docs/en/config/index.mdx +++ b/website/docs/en/config/index.mdx @@ -153,10 +153,11 @@ const { merge } = require('webpack-merge'); const base = {}; const dev = { - plugins: [new DevelopmentSpecifiedPlugin()] + plugins: [new DevelopmentSpecifiedPlugin()], }; -module.exports = process.env.NODE_ENV === 'development' ? merge(base, dev) : base; +module.exports = + process.env.NODE_ENV === 'development' ? merge(base, dev) : base; ``` For more information of `merge`, please refer to [webpack-merge documentation](https://npmjs.com/package/webpack-merge). diff --git a/website/docs/zh/config/dev-server.mdx b/website/docs/zh/config/dev-server.mdx index 4e9da69090b..0d97f39142f 100644 --- a/website/docs/zh/config/dev-server.mdx +++ b/website/docs/zh/config/dev-server.mdx @@ -4,7 +4,7 @@ import WebpackLicense from '@components/WebpackLicense'; # DevServer -该选项用于配置 [`@rspack/dev-server`](https://github.com/web-infra-dev/rspack/tree/main/packages/rspack-dev-server) 的行为,基于 `webpack-dev-server@5`,用于快速开发应用程序。 +该选项用于配置 [`@rspack/dev-server`](https://github.com/web-infra-dev/rspack-dev-server) 的行为,基于 `webpack-dev-server@5`,用于快速开发应用程序。 - **类型:** `object` diff --git a/website/docs/zh/config/index.mdx b/website/docs/zh/config/index.mdx index 91ac6390851..686ad4ea18d 100644 --- a/website/docs/zh/config/index.mdx +++ b/website/docs/zh/config/index.mdx @@ -151,10 +151,11 @@ const { merge } = require('webpack-merge'); const base = {}; const dev = { - plugins: [new DevelopmentSpecifiedPlugin()] + plugins: [new DevelopmentSpecifiedPlugin()], }; -module.exports = process.env.NODE_ENV === 'development' ? merge(base, dev) : base; +module.exports = + process.env.NODE_ENV === 'development' ? merge(base, dev) : base; ``` 关于 `merge` 的更多信息请查看 [webpack-merge 文档](https://npmjs.com/package/webpack-merge)。