Skip to content

Commit

Permalink
test: remove redundant test cases related to 3rd party code (#4131)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Akait <4567934+alexander-akait@users.noreply.github.com>
  • Loading branch information
snitin315 and alexander-akait committed Dec 23, 2021
1 parent 0dd1ee6 commit ff4550e
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions test/server/Server.test.js
Expand Up @@ -2,29 +2,18 @@

const { relative, sep } = require("path");
const webpack = require("webpack");
const sockjs = require("sockjs/lib/transport");
const Server = require("../../lib/Server");
const config = require("../fixtures/simple-config/webpack.config");
const port = require("../ports-map").server;
const isWebpack5 = require("../helpers/isWebpack5");

jest.mock("sockjs/lib/transport");

const baseDevConfig = {
port,
host: "localhost",
static: false,
};

describe("Server", () => {
describe("sockjs has decorateConnection", () => {
it("add decorateConnection", () => {
expect(typeof sockjs.Session.prototype.decorateConnection).toEqual(
"function"
);
});
});

describe("DevServerPlugin", () => {
let entries;

Expand Down Expand Up @@ -115,50 +104,4 @@ describe("Server", () => {
utilSpy.mockRestore();
});
});

// issue: https://github.com/webpack/webpack-dev-server/issues/1724
describe("express.static.mime.types", () => {
it("should success even if mime.types doesn't exist", async () => {
// expect.assertions(1);

jest.mock("express", () => {
const data = jest.requireActual("express");
const { static: st } = data;
const { mime } = st;

delete mime.types;

expect(typeof mime.types).toEqual("undefined");

return { ...data, static: { ...st, mime } };
});

const compiler = webpack(config);
const server = new Server(baseDevConfig, compiler);

let hasStats = false;

compiler.hooks.done.tap("webpack-dev-server", (s) => {
const output = server.getStats(s);

expect(output.errors.length).toEqual(0);

hasStats = true;
});

await server.start();

await new Promise((resolve) => {
const interval = setInterval(() => {
if (hasStats) {
resolve();

clearInterval(interval);
}
}, 100);
});

await server.stop();
});
});
});

0 comments on commit ff4550e

Please sign in to comment.