vitest-websocket-mock 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -319,7 +319,7 @@ under the hood to mock out WebSocket clients.
319
319
  Out of the box, Mock Socket will only mock out the global `WebSocket` object.
320
320
  If you are using a third-party WebSocket client library (eg. a Node.js
321
321
  implementation, like [`ws`](https://github.com/websockets/ws)), you'll need
322
- to set up a [manual mock](https://jestjs.io/docs/en/manual-mocks#mocking-node-modules):
322
+ to set up a [manual mock](https://vitest.dev/api/vi.html#vi-mock):
323
323
 
324
324
  - Create a `__mocks__` folder in your project root
325
325
  - Add a new file in the `__mocks__` folder named after the library you want to
@@ -333,6 +333,19 @@ to set up a [manual mock](https://jestjs.io/docs/en/manual-mocks#mocking-node-mo
333
333
  export { WebSocket as default } from 'mock-socket';
334
334
  ```
335
335
 
336
+ - Somewhere in the test files, call `vi.mock` with the name of the library you want to mock. For instance, for the `ws` library:
337
+
338
+ ```js
339
+ // foo.test.js
340
+
341
+ import WebSocket from 'ws';
342
+ import { vi } from 'vitest';
343
+
344
+ vi.mock('ws');
345
+
346
+ // do some tests...
347
+ ```
348
+
336
349
  **NOTE** The `ws` library is not 100% compatible with the browser API, and
337
350
  the `mock-socket` library that `vitest-websocket-mock` uses under the hood only
338
351
  implements the browser API.
package/dist/index.js CHANGED
@@ -241,7 +241,7 @@ Received:
241
241
  var toHaveReceivedMessages_default = toHaveReceivedMessages;
242
242
 
243
243
  // src/matchers/toReceiveMessage.ts
244
- import { diff } from "jest-diff";
244
+ import { diff } from "@vitest/utils/diff";
245
245
  var toReceiveMessage = deriveToReceiveMessage("toReceiveMessage", function(received, expected) {
246
246
  const pass = this.equals(received, expected);
247
247
  const message = pass ? () => this.utils.matcherHint(".not.toReceiveMessage", "WS", "expected") + `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-websocket-mock",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Mock websockets and assert complex websocket interactions with Vitest",
5
5
  "type": "module",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "devDependencies": {
37
37
  "@typescript-eslint/eslint-plugin": "^5.59.0",
38
38
  "@typescript-eslint/parser": "^5.59.0",
39
- "@vitest/coverage-v8": "^1.0.2",
39
+ "@vitest/coverage-v8": "^3.0.0",
40
40
  "eslint": "^8.38.0",
41
41
  "eslint-config-prettier": "^8.5.0",
42
42
  "eslint-config-react-app": "^7.0.1",
@@ -48,13 +48,13 @@
48
48
  "tsup": "^7.0.0",
49
49
  "typescript": "^4.0.2",
50
50
  "vite": "^5.0.6",
51
- "vitest": "^1.0.2"
51
+ "vitest": "^3.0.0"
52
52
  },
53
53
  "peerDependencies": {
54
- "vitest": ">=1 <2"
54
+ "vitest": ">=3"
55
55
  },
56
56
  "dependencies": {
57
- "jest-diff": "^29.2.0",
57
+ "@vitest/utils": "^3.0.0",
58
58
  "mock-socket": "^9.2.1"
59
59
  },
60
60
  "files": [