Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

test: remove old and redundant test cases related to 3rd party code #4131

Merged
merged 2 commits into from
Dec 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
);
});
Comment on lines -21 to -25
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3rd party code

});

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", () => {
Copy link
Member Author

@snitin315 snitin315 Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added for a workaround logic that doesn't exist anymore. #1580 #1765

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();
});
});
});