|
2 | 2 |
|
3 | 3 | const { relative, sep } = require("path"); |
4 | 4 | const webpack = require("webpack"); |
5 | | -const sockjs = require("sockjs/lib/transport"); |
6 | 5 | const Server = require("../../lib/Server"); |
7 | 6 | const config = require("../fixtures/simple-config/webpack.config"); |
8 | 7 | const port = require("../ports-map").server; |
9 | 8 | const isWebpack5 = require("../helpers/isWebpack5"); |
10 | 9 |
|
11 | | -jest.mock("sockjs/lib/transport"); |
12 | | - |
13 | 10 | const baseDevConfig = { |
14 | 11 | port, |
15 | 12 | host: "localhost", |
16 | 13 | static: false, |
17 | 14 | }; |
18 | 15 |
|
19 | 16 | describe("Server", () => { |
20 | | - describe("sockjs has decorateConnection", () => { |
21 | | - it("add decorateConnection", () => { |
22 | | - expect(typeof sockjs.Session.prototype.decorateConnection).toEqual( |
23 | | - "function" |
24 | | - ); |
25 | | - }); |
26 | | - }); |
27 | | - |
28 | 17 | describe("DevServerPlugin", () => { |
29 | 18 | let entries; |
30 | 19 |
|
@@ -115,50 +104,4 @@ describe("Server", () => { |
115 | 104 | utilSpy.mockRestore(); |
116 | 105 | }); |
117 | 106 | }); |
118 | | - |
119 | | - // issue: https://github.com/webpack/webpack-dev-server/issues/1724 |
120 | | - describe("express.static.mime.types", () => { |
121 | | - it("should success even if mime.types doesn't exist", async () => { |
122 | | - // expect.assertions(1); |
123 | | - |
124 | | - jest.mock("express", () => { |
125 | | - const data = jest.requireActual("express"); |
126 | | - const { static: st } = data; |
127 | | - const { mime } = st; |
128 | | - |
129 | | - delete mime.types; |
130 | | - |
131 | | - expect(typeof mime.types).toEqual("undefined"); |
132 | | - |
133 | | - return { ...data, static: { ...st, mime } }; |
134 | | - }); |
135 | | - |
136 | | - const compiler = webpack(config); |
137 | | - const server = new Server(baseDevConfig, compiler); |
138 | | - |
139 | | - let hasStats = false; |
140 | | - |
141 | | - compiler.hooks.done.tap("webpack-dev-server", (s) => { |
142 | | - const output = server.getStats(s); |
143 | | - |
144 | | - expect(output.errors.length).toEqual(0); |
145 | | - |
146 | | - hasStats = true; |
147 | | - }); |
148 | | - |
149 | | - await server.start(); |
150 | | - |
151 | | - await new Promise((resolve) => { |
152 | | - const interval = setInterval(() => { |
153 | | - if (hasStats) { |
154 | | - resolve(); |
155 | | - |
156 | | - clearInterval(interval); |
157 | | - } |
158 | | - }, 100); |
159 | | - }); |
160 | | - |
161 | | - await server.stop(); |
162 | | - }); |
163 | | - }); |
164 | 107 | }); |
0 commit comments