MCPcopy
hub / github.com/webpack/webpack-dev-server / installMocks

Function installMocks

test/client/index.test.js:25–56  ·  view source on GitHub ↗

* Install fresh mock.module() interceptors for the four modules * client-src/index.js loads at evaluation time. * @returns {void}

()

Source from the content-addressed store, hash-verified

23 * @returns {void}
24 */
25 function installMocks() {
26 log = {
27 log: { info: fn(), warn: fn(), error: fn() },
28 logEnabledFeatures: fn(),
29 setLogLevel: fn(),
30 };
31 logMockCtx = mock.module("../../client-src/utils/log.js", {
32 namedExports: log,
33 });
34
35 socket = fn();
36 socketMockCtx = mock.module("../../client-src/socket.js", {
37 defaultExport: socket,
38 });
39
40 const send = fn();
41 overlay = { send };
42 overlayMockCtx = mock.module("../../client-src/overlay.js", {
43 namedExports: {
44 createOverlay: () => overlay,
45 formatProblem: (item) => ({
46 header: "HEADER warning",
47 body: `BODY: ${item}`,
48 }),
49 },
50 });
51
52 sendMessage = fn();
53 sendMessageMockCtx = mock.module("../../client-src/utils/sendMessage.js", {
54 defaultExport: sendMessage,
55 });
56 }
57
58 /**
59 * Tear down the mock.module() interceptors installed by installMocks().

Callers 1

index.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…