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

Function createMockClient

test/client/socket-helper.test.js:13–25  ·  view source on GitHub ↗

* Build a fresh mock WebSocketClient class. Each `new MockClient(url)` * registers the instance and arguments on the static `.mock` so tests can * assert on them. * @returns {new (url: string) => unknown} mock client constructor

()

Source from the content-addressed store, hash-verified

11 * @returns {new (url: string) => unknown} mock client constructor
12 */
13function createMockClient() {
14 class MockClient {
15 constructor(url) {
16 MockClient.mock.instances.push(this);
17 MockClient.mock.calls.push([url]);
18 this.onOpen = fn();
19 this.onClose = fn();
20 this.onMessage = fn();
21 }
22 }
23 MockClient.mock = { instances: [], calls: [] };
24 return MockClient;
25}
26
27describe("socket", () => {
28 beforeEach(() => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…