{"_id":"vitest-websocket-mock","_rev":"14-df1cc8a9d2f06f2e4fbf3aa2348072b7","name":"vitest-websocket-mock","dist-tags":{"latest":"0.8.0"},"versions":{"0.1.0":{"name":"vitest-websocket-mock","version":"0.1.0","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.1.0","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"edfc0d41940fc4c92a943509be12e0dfd1f87303","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.1.0.tgz","fileCount":17,"integrity":"sha512-ycJE82n+FmI+VLvHX16n16U9a9SoYWuS6B3pgcKWmqsvTNKz9axvo1QM273cMz/CM8AA8EAEFhKXMXReZpMv7Q==","signatures":[{"sig":"MEUCIHNTJZUuHMYrahKi9lr0WU5Q4Uz75qmw3jbzYZqkAumSAiEA4gKGr69lKaJsV5VHJs78H+yJcgNbb1wbFNjYEt+RwlA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1293762},"type":"module","types":"dist/index.d.ts","module":"dist/index.es.js","exports":{".":{"types":"dist/index.d.ts","import":"dist/index.es.js"}},"gitHead":"726f5d23ef3600d30c16086f88fad5fe1a028589","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"vite build && tsc -p tsconfig.build.json","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.5.1","description":"Mock websockets and assert complex websocket interactions with Jest","directories":{},"_nodeVersion":"18.16.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.1.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^4.3.9","eslint":"^8.28.0","rimraf":"^4.1.2","vitest":"^0.31.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-c8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.45.0","vite-plugin-node-stdlib-browser":"^0.2.1","@typescript-eslint/eslint-plugin":"^5.45.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":"^0.31.0"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.1.0_1686953248114_0.2648979682048411","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"vitest-websocket-mock","version":"0.1.1","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.1.1","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"b7a7934b3f31259d388941d9d3a4a173d606abab","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.1.1.tgz","fileCount":17,"integrity":"sha512-mDi1IX1irUoGLUUyneontSR5O+rZANYT6EeyA9fCJ4gyWIUFssZlB3pHp/cis26iKXAep6fX9GPAex/VCH9/GQ==","signatures":[{"sig":"MEQCIQDjkWsn9hYCpkOF92KIBBuqotPAnmQaqQeBtsBaKZGHsAIfDhGA8WEfDdgFEZGz9I08tLrhjLCUDLXmclejrsVtaQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1293768},"type":"module","types":"dist/index.d.ts","module":"dist/index.es.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.es.js"}},"gitHead":"132843e6009b3a9651bc9aace660a6dd7e994360","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"vite build && tsc -p tsconfig.build.json","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.5.1","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"18.16.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.1.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^4.3.9","eslint":"^8.28.0","rimraf":"^4.1.2","vitest":"^0.31.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-c8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.45.0","vite-plugin-node-stdlib-browser":"^0.2.1","@typescript-eslint/eslint-plugin":"^5.45.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":"^0.31.0"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.1.1_1686995474758_0.7123598105315418","host":"s3://npm-registry-packages"}},"0.1.2":{"name":"vitest-websocket-mock","version":"0.1.2","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.1.2","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"aee5718c00e71e78acf599241f8bb2632aa6b184","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.1.2.tgz","fileCount":5,"integrity":"sha512-PSnin0GOV8dr2jnJ6NQo9x/5wjl5Ay8Chjfk4j7QaG1whOhRriB79qnCNID0H+uLcgE8TaXr3LgbWt1Vg/N7bw==","signatures":[{"sig":"MEYCIQCIOONgj2Lg+oDSHYBNecvePp7kU9VkNlSpkQrpkzWidwIhALq0bs7b3UkWdsih6BNMcoPpRYMCpciC8XE6oZjFbfgD","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25237},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"44725c6252ca6c249a6ecb1c4d9f22231630d6f0","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.5.1","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"18.16.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^4.3.9","eslint":"^8.28.0","rimraf":"^4.1.2","vitest":"^0.31.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-c8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.45.0","@typescript-eslint/eslint-plugin":"^5.45.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":"^0.31.0"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.1.2_1686997824439_0.3591304652522016","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"vitest-websocket-mock","version":"0.1.3","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.1.3","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"ec8341ea1ababbaba1fa003213de931e1c48e5cf","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.1.3.tgz","fileCount":5,"integrity":"sha512-tB0rIhwV5bzwkHD5+iJU5WER8qdSSzgzZQxiBPtZlJJJC8VPPJG4K/tlWXr1DKBD+SeeIld3sOqeoQh7tXZxuA==","signatures":[{"sig":"MEUCIDsdByRSVjJCWvVyn+S4Evm09blJvmlqg/DevyzBTfxjAiEAxy/A7KeaOxVpYRgDviw7mvwDR7KrNNa4GxTD6pMzuqY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25214},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"922a70a9d50a3de1c5cc38ceee8923cb0de70772","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.5.1","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"18.16.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^4.3.9","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^0.32.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":"^0.32.0"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.1.3_1687105630415_0.539571812324086","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"vitest-websocket-mock","version":"0.2.0","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.2.0","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"cf559c387d816134252c22d8cdffa23442a3e4f1","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.2.0.tgz","fileCount":5,"integrity":"sha512-bIeEiH+qmxrDr+gH+nXk0hKnTmV6PyNQB6offvZ28YbSKVaNbfxdycqycmnV9/DeHjCXniVWmXhpoCi6OivfgA==","signatures":[{"sig":"MEQCIBnOn+p20+wEr65O8balHrN/1/Aqf6A69nJpL4pxjKkYAiBciDf8Q1H7KI3AWdiWELHy17aGfN9SolCRC4TwaESL0w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":24354},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"5137c946517cfc0c37061a5eddbd20e510f67395","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.5.1","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"18.16.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.2.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^4.3.9","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^0.32.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":"^0.32.0"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.2.0_1687447317849_0.13558467632858906","host":"s3://npm-registry-packages"}},"0.2.1":{"name":"vitest-websocket-mock","version":"0.2.1","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.2.1","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"54da7480b5d8af98e43808568efac9063602435b","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.2.1.tgz","fileCount":5,"integrity":"sha512-qcV5xsYqAvGIvC3eWxoIfaLPTXbm8JmA7Co0kO/89LPg5Rb7gUddE8apHPpGnWivq7JvstpyOO4PQcla3Y0EEw==","signatures":[{"sig":"MEUCIFyXLfJOmtz9S4DcjaZqA5fQIvHhV0d1y5LJqn1pdU4+AiEAwqw7qcpuYgGfhV43i7jlGnKZX+sZMEYGG/WUMvMeza0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":24692},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"c8945694ed6249a72fcab052aa372720763a85f0","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.5.1","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"18.16.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.2.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^4.3.9","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^0.32.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":"^0.32.0"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.2.1_1687700221384_0.5079604796194583","host":"s3://npm-registry-packages"}},"0.2.2":{"name":"vitest-websocket-mock","version":"0.2.2","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.2.2","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"d2052bddc6125ef065d1733b9ade1b209f292717","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.2.2.tgz","fileCount":5,"integrity":"sha512-S/tZjCmYHxXmticnclsOBDxU8mPgdFHA5rao2CK2s17gZSbxC7u+RN268uckQ8y3Z/wtnbWG2Y9DDHUeAZJL0g==","signatures":[{"sig":"MEUCIBhLcCulp26c2+Y3HP1SQpRqsKBA5J0yip081T0HmuSQAiEAiygMsal9JyC9C9l17aqOEiH9TNwqlX3FxlCtbdZVkZs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25585},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"74acd98e52528911e4db53092ac96ec0f87be84e","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.5.1","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"18.16.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.2.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^4.3.9","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^0.32.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":">=0.31.0 <1"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.2.2_1687908244335_0.06475102246484732","host":"s3://npm-registry-packages"}},"0.2.3":{"name":"vitest-websocket-mock","version":"0.2.3","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.2.3","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"664a17a3f3ec38283810e4191dcc159c55b5fa33","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.2.3.tgz","fileCount":5,"integrity":"sha512-Ea2CcXHWJj/DhXcFeZsAjCPQ/SD0LDkin8k5zexq4/1izaPqRROta4eYCBbD3l9NfEWOnvrcOPkk+jNNieLCWQ==","signatures":[{"sig":"MEQCIB9NmDBD5vITIG/dcWS+lRt40SXa/fm54SRyPnI9I4pQAiBdouy7p9XtsJvo5MCbKEv4PG/pt/TWpxH5YxdnmC1v6w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25581},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"dfa41fa938cc29795faac7e005cd1b14f1f1d5a9","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"9.8.1","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"18.18.2","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.2.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^4.3.9","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^0.32.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^0.32.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":">=0.31.0 <1"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.2.3_1701962052369_0.5041611728705333","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"vitest-websocket-mock","version":"0.3.0","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.3.0","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"cf60696108fc00647bf14bd6521f50c8678c1cb6","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.3.0.tgz","fileCount":5,"integrity":"sha512-kTEFtfHIUDiiiEBj/CR6WajugqObjnuNdolGRJA3vo3Xt+fmfd1Ghwe+NpJytG6OE57noHOCUXzs2R9XUF0cwg==","signatures":[{"sig":"MEQCIFTq6W7Gq1hbKELBQRGsFB1dcbNOhzyGdzaaYW5GG6xdAiAhb32YXU8CH+RKO0ZyiJvV9JK27QzdcxOeb+SPDFjktg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25574},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"6ab8e3579043e3899f1df7c0ce52927d9a0cab5c","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"10.2.3","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"20.10.0","dependencies":{"jest-diff":"^29.2.0","mock-socket":"^9.2.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^5.0.6","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^1.0.2","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^1.0.2","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":">=1 <2"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.3.0_1701965110380_0.3594550980959501","host":"s3://npm-registry-packages"}},"0.4.0":{"name":"vitest-websocket-mock","version":"0.4.0","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.4.0","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"60626759d44adf0f6c3a5576eae7aea30abb1b3c","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.4.0.tgz","fileCount":5,"integrity":"sha512-tGnOwE2nC8jfioQXDrX+lZ8EVrF+IO2NVqe1vV9h945W/hlR0S6ZYbMqCJGG3Nyd//c5XSe1IGLD2ZgE2D1I7Q==","signatures":[{"sig":"MEYCIQDBumZguiU6zKMMuHgo5uJfB4JDaGh/tK2IMztXg/6v+AIhAJGjdJFyGpNn+QpRZgY0uj5G9iSAi4ogIuF+S6AUpp5o","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":25583},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"05a0dc81dafdbc18a55e7dd4282c84497d3060a4","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"10.8.2","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"20.17.0","dependencies":{"mock-socket":"^9.2.1","@vitest/utils":"^2.0.3"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^5.0.6","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^2.0.3","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^2.0.3","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":">=2"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.4.0_1725282565802_0.5099965735377399","host":"s3://npm-registry-packages"}},"0.5.0":{"name":"vitest-websocket-mock","version":"0.5.0","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.5.0","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"b81cd41a65f27d568ccfaabc7dd608c5df0c7e0e","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.5.0.tgz","fileCount":5,"integrity":"sha512-vzBWeuF/kD/OCOFzB7WAclb7PxfI105qPkZtdOkPMwZdilBskQjJL4l319JtPtmeovDU7ZVhO3hTfGPjM4txQQ==","signatures":[{"sig":"MEQCIBh4TEVshINcOO8EgQCwJGLN22AupcZzLpu1NT0X5ShDAiAB9UozUOnZTdfhyCSlqGJhs609W/iXKnJ5FPpXhLOSjw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":25813},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"1b49dc953277a9b6ed20e5e902b2fbbc7fe64044","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"akiomik","email":"akiomik@gmail.com"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"10.8.2","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"20.19.0","dependencies":{"mock-socket":"^9.2.1","@vitest/utils":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","vite":"^5.0.6","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"^3.0.0","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"^3.0.0","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":">=3"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.5.0_1742868409791_0.9845296528215008","host":"s3://npm-registry-packages-npm-production"}},"0.6.0":{"name":"vitest-websocket-mock","version":"0.6.0","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.6.0","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"7fc2b393b6ab5afedd22347e6bbd3becf9eb5492","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.6.0.tgz","fileCount":5,"integrity":"sha512-gyLWaLcPTyis3PG8qD3e0prMACaF0oH7BLw0KXZj1m93jSxQtL5NGCmgUfL8BR7oierJQeiIx5kHljRCkEGj0g==","signatures":[{"sig":"MEYCIQCaPhn5schRqrvnFP/X+xR39W+xIM2kQJr/G5oXkLxFCgIhAPWufg/oMmAM5YmIfhnIiL5Q5meM5BrobR/9yFuvhDzv","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/vitest-websocket-mock@0.6.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":25878},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"307d1f937516917b53abaa6e0b90a88d7e205223","scripts":{"lint":"prettier --check . && eslint .","test":"vitest --run","build":"tsup","clean":"rimraf dist","format":"prettier --write .","prebuild":"npm run clean","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:747baafd-4084-4cd1-8396-81aff7e47a66"}},"overrides":{"esbuild":"^0.28.1"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"11.16.0","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"24.18.0","dependencies":{"mock-socket":"^9.2.1","@vitest/utils":"4.1.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","vite":"^8.1.4","eslint":"^8.38.0","rimraf":"^4.1.2","vitest":"4.1.1","prettier":"^2.0.2","typescript":"^4.0.2","@vitest/coverage-v8":"4.1.1","eslint-config-prettier":"^8.5.0","eslint-config-react-app":"^7.0.1","@typescript-eslint/parser":"^5.59.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.3.4","@typescript-eslint/eslint-plugin":"^5.59.0","eslint-plugin-simple-import-sort":"^10.0.0"},"peerDependencies":{"vitest":">=4"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.6.0_1783791657483_0.6699917556786414","host":"s3://npm-registry-packages-npm-production"}},"0.7.0":{"name":"vitest-websocket-mock","version":"0.7.0","keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","_id":"vitest-websocket-mock@0.7.0","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"dist":{"shasum":"5f6f07f25853d8cd3db96ecdd8d4c3b26e834103","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.7.0.tgz","fileCount":5,"integrity":"sha512-OrDWs/FiZl8MfcCjvxLri1Uq2NpFcqbQdFHuotmU5FgA9Z5PHRxCyHdmu/xSPgBzbxO9pz3ZdHtokFELCT7AOg==","signatures":[{"sig":"MEUCIBhVRO6YZl7CbH0taDozS/JtTCBfSD6Mpf/LAS898i+yAiEAiyU3bCDmfv6QB3nDIKM3JPziYqxO/bzEnn0VMIBJidU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/vitest-websocket-mock@0.7.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26532},"type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"ab87f608175a742cc6ebd1a66003837696f8baeb","scripts":{"lint":"biome check .","test":"vitest --run","build":"tsdown","clean":"rimraf dist","format":"biome check --write .","prebuild":"npm run clean","typecheck":"tsc --noEmit","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:747baafd-4084-4cd1-8396-81aff7e47a66"}},"overrides":{"esbuild":"^0.28.1"},"repository":{"url":"git+https://github.com/akiomik/vitest-websocket-mock.git","type":"git"},"_npmVersion":"11.17.0","description":"Mock websockets and assert complex websocket interactions with Vitest","directories":{},"_nodeVersion":"26.5.0","dependencies":{"mock-socket":"^9.2.1"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.1.4","rimraf":"^4.1.2","tsdown":"^0.22.5","vitest":"^4.1.10","typescript":"^7.0.2","@types/node":"^26.1.1","@biomejs/biome":"^2.5.3","@vitest/coverage-v8":"^4.1.10"},"peerDependencies":{"vitest":">=4"},"_npmOperationalInternal":{"tmp":"tmp/vitest-websocket-mock_0.7.0_1783803517555_0.44693854251262843","host":"s3://npm-registry-packages-npm-production"}},"0.8.0":{"name":"vitest-websocket-mock","version":"0.8.0","description":"Mock websockets and assert complex websocket interactions with Vitest","type":"module","repository":{"type":"git","url":"git+https://github.com/akiomik/vitest-websocket-mock.git"},"types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"clean":"rimraf dist","prebuild":"npm run clean","build":"tsdown","typecheck":"tsc --noEmit","lint":"biome check .","format":"biome check --write .","prepublishOnly":"npm run build","test":"vitest --run","test:watch":"vitest"},"keywords":["vitest","websocket","mock","unit-testing"],"author":{"name":"Akiomi Kamakura"},"license":"MIT","devDependencies":{"@biomejs/biome":"^2.5.3","@types/node":"^26.1.1","@vitest/coverage-v8":"^5.0.0","rimraf":"^6.1.3","tsdown":"^0.23.0","typescript":"^7.0.2","vite":"^8.1.4","vitest":"^5.0.0"},"peerDependencies":{"vitest":">=5 <6"},"dependencies":{"mock-socket":"^9.2.1"},"overrides":{"esbuild":"^0.28.1"},"gitHead":"32681f06aa17deef1cf4566cf0da3d007dd99c96","_id":"vitest-websocket-mock@0.8.0","bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","_nodeVersion":"26.8.2","_npmVersion":"11.19.1","dist":{"integrity":"sha512-HYPmK7bNfEpbyRh6mg72XpHKzyxcfa7kUCSi7HrTy7K0WvqClLZstTHbwzBb9XpshOy+B8ElH+M0a9A/qnD4fA==","shasum":"894ac0774bb047ef6fdd7c83a4fc893c4f602242","tarball":"https://registry.npmjs.org/vitest-websocket-mock/-/vitest-websocket-mock-0.8.0.tgz","fileCount":5,"unpackedSize":28413,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/vitest-websocket-mock@0.8.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEJGXolk3uDCEjMHl8SCdUZkiJ7hqAkvdQFEi3hWR6XPAiBkWbvkrCIZ4zQJmvrmdODfnJDgF56nui+DOGTeSMiusg=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:747baafd-4084-4cd1-8396-81aff7e47a66"}},"directories":{},"maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vitest-websocket-mock_0.8.0_1789043395082_0.6813415591092813"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-16T22:07:28.113Z","modified":"2026-09-10T12:29:55.544Z","0.1.0":"2023-06-16T22:07:28.403Z","0.1.1":"2023-06-17T09:51:14.966Z","0.1.2":"2023-06-17T10:30:24.600Z","0.1.3":"2023-06-18T16:27:10.614Z","0.2.0":"2023-06-22T15:21:58.045Z","0.2.1":"2023-06-25T13:37:01.578Z","0.2.2":"2023-06-27T23:24:04.518Z","0.2.3":"2023-12-07T15:14:12.596Z","0.3.0":"2023-12-07T16:05:10.601Z","0.4.0":"2024-09-02T13:09:25.966Z","0.5.0":"2025-03-25T02:06:50.011Z","0.6.0":"2026-07-11T17:40:57.630Z","0.7.0":"2026-07-11T20:58:37.691Z","0.8.0":"2026-09-10T12:29:55.213Z"},"bugs":{"url":"https://github.com/akiomik/vitest-websocket-mock/issues"},"author":{"name":"Akiomi Kamakura"},"license":"MIT","homepage":"https://github.com/akiomik/vitest-websocket-mock#readme","keywords":["vitest","websocket","mock","unit-testing"],"repository":{"type":"git","url":"git+https://github.com/akiomik/vitest-websocket-mock.git"},"description":"Mock websockets and assert complex websocket interactions with Vitest","maintainers":[{"name":"akiomik","email":"akiomik@gmail.com"}],"readme":"# vitest-websocket-mock\n\n[![npm version](https://badge.fury.io/js/vitest-websocket-mock.svg)](https://badge.fury.io/js/vitest-websocket-mock)\n[![Build Status](https://github.com/akiomik/vitest-websocket-mock/actions/workflows/ci.yml/badge.svg)](https://github.com/akiomik/vitest-websocket-mock/actions)\n[![codecov](https://codecov.io/gh/akiomik/vitest-websocket-mock/branch/main/graph/badge.svg?token=40OVYIT90L)](https://codecov.io/gh/akiomik/vitest-websocket-mock)\n\nA set of utilities and Vitest matchers to help testing complex websocket interactions:\nmock websocket servers, wait for connections and messages, and assert on them\nwith dedicated matchers.\n\nOriginally forked from [romgain/jest-websocket-mock](https://github.com/romgain/jest-websocket-mock),\nand since developed independently as a Vitest-first library.\n\n**Examples:**\nSeveral examples are provided in the [examples folder](https://github.com/akiomik/vitest-websocket-mock/blob/main/examples/).\nIn particular:\n\n- [testing a redux saga that manages a websocket connection](https://github.com/akiomik/vitest-websocket-mock/blob/main/examples/redux-saga/src/__tests__/saga.test.ts)\n- [testing a component using the saga above](https://github.com/akiomik/vitest-websocket-mock/blob/main/examples/redux-saga/src/__tests__/App.test.tsx)\n- [testing a component that manages a websocket connection using react hooks](https://github.com/akiomik/vitest-websocket-mock/blob/main/examples/hooks/src/App.test.tsx)\n\n## When to use this vs. MSW\n\n[Vitest recommends](https://vitest.dev/guide/mocking/requests) [Mock Service Worker (MSW)](https://mswjs.io)\nfor mocking network requests, and MSW has first-class\n[WebSocket support](https://mswjs.io/docs/websocket/). The two address different\nlayers of the problem:\n\n- **MSW** provides declarative, network-level mocking (`ws.link()` handlers).\n  It shines when you want to share handlers between your app, Storybook, and\n  tests, or when you also need to mock HTTP or GraphQL.\n- **`vitest-websocket-mock`** provides imperative test-flow ergonomics that MSW\n  does not: a `WS` mock-server object, `await server.connected`, a synchronous\n  record of received messages in `server.messages`, and custom matchers such as\n  `.toReceiveMessage` and `.toHaveReceivedMessages`.\n\nIf your test reads best as a step-by-step conversation with a mock server\n(\"wait for the connection, assert on the next message, reply, assert again\"),\nthis library is the better fit. Running this library on top of MSW's\ninterceptor, which would make the two complementary rather than alternatives,\nis being explored in [#77](https://github.com/akiomik/vitest-websocket-mock/issues/77).\n\n## Install\n\n`vitest-websocket-mock` requires Vitest 5 as a peer dependency.\n\n```bash\nnpm install -D vitest-websocket-mock\n```\n\n## Mock a websocket server\n\n### The `WS` constructor\n\n`vitest-websocket-mock` exposes a `WS` class that can instantiate mock websocket\nservers that keep track of the messages they receive, and in turn\ncan send messages to connected clients.\n\n```js\nimport WS from 'vitest-websocket-mock';\n\n// create a WS instance, listening on port 1234 on localhost\nconst server = new WS('ws://localhost:1234');\n\n// real clients can connect\nconst client = new WebSocket('ws://localhost:1234');\nawait server.connected; // wait for the server to have established the connection\n\n// the mock websocket server will record all the messages it receives\nclient.send('hello');\n\n// the mock websocket server can also send messages to all connected clients\nserver.send('hello everyone');\n\n// ...simulate an error and close the connection\nserver.error();\n\n// ...or gracefully close the connection\nserver.close();\n\n// The WS class also has a static \"clean\" method to gracefully close all open connections,\n// particularly useful to reset the environment between test runs.\nWS.clean();\n```\n\nThe `WS` constructor also accepts an optional options object as second argument:\n\n- `jsonProtocol: true` can be used to automatically serialize and deserialize JSON messages:\n\n```js\nconst server = new WS('ws://localhost:1234', { jsonProtocol: true });\nserver.send({ type: 'GREETING', payload: 'hello' });\n```\n\n- The [`mock-socket`](https://github.com/thoov/mock-socket) server options `verifyClient` and `selectProtocol` are directly passed through to the underlying mock server's constructor.\n\n### Attributes of a `WS` instance\n\nA `WS` instance has the following attributes:\n\n- `connected`: a Promise that resolves every time the `WS` instance receives a\n  new connection. The resolved value is the `WebSocket` instance that initiated\n  the connection.\n- `closed`: a Promise that resolves every time a connection to a `WS` instance\n  is closed.\n- `nextMessage`: a Promise that resolves every time a `WS` instance receives a\n  new message. The resolved value is the received message (deserialized as a\n  JavaScript Object if the `WS` was instantiated with the `{ jsonProtocol: true }`\n  option).\n- `messages`: an array that synchronously and cumulatively records every\n  message received by the `WS` instance, in the order they were received.\n  Since it's updated synchronously, it can be used to assert that no message\n  has been received without waiting on a timeout (see\n  [Run assertions on received messages](#run-assertions-on-received-messages)).\n\n### Methods on a `WS` instance\n\n- `send`: send a message to all connected clients. (The message will be\n  serialized from a JavaScript Object to a JSON string if the `WS` was\n  instantiated with the `{ jsonProtocol: true }` option).\n- `close`: gracefully closes all opened connections.\n- `error`: sends an error message to all connected clients and closes all\n  opened connections.\n- `on`: attach event listeners to handle new `connection`, `message` and `close` events. The callback receives the `socket` as its only argument.\n\n## Run assertions on received messages\n\n`vitest-websocket-mock` registers custom Vitest matchers to make assertions\non received messages easier. They are registered automatically when\n`vitest-websocket-mock` is imported, so no extra setup file is needed:\n\n- `.toReceiveMessage`: async matcher that waits for the next message received\n  by the mock websocket server, and asserts its content. It will time out\n  with a helpful message after 1000ms.\n- `.toHaveReceivedMessages`: synchronous matcher that checks that all the\n  expected messages have been received by the mock websocket server.\n\n**Note**: `.toHaveReceivedMessages([])` always passes, since it only checks\nthat every expected message is included in the received messages, and an\nempty list of expected messages is trivially satisfied. To assert that _no_\nmessage has been received, check `server.messages` directly instead (see\nbelow).\n\n### Run assertions on messages as they are received by the mock server\n\n```js\ntest('the server keeps track of received messages, and yields them as they come in', async () => {\n  const server = new WS('ws://localhost:1234');\n  const client = new WebSocket('ws://localhost:1234');\n\n  await server.connected;\n  client.send('hello');\n  await expect(server).toReceiveMessage('hello');\n  expect(server).toHaveReceivedMessages(['hello']);\n});\n```\n\n### Assert that a message has not been received\n\n`server.messages` is updated synchronously, so it can be checked immediately\nwithout waiting for a timeout:\n\n```js\ntest('asserts that no message has been received', async () => {\n  const server = new WS('ws://localhost:1234');\n  const client = new WebSocket('ws://localhost:1234');\n\n  await server.connected;\n  expect(server.messages).toEqual([]);\n});\n```\n\n### Send messages to the connected clients\n\n```js\ntest('the mock server sends messages to connected clients', async () => {\n  const server = new WS('ws://localhost:1234');\n  const client1 = new WebSocket('ws://localhost:1234');\n  await server.connected;\n  const client2 = new WebSocket('ws://localhost:1234');\n  await server.connected;\n\n  const messages = { client1: [], client2: [] };\n  client1.onmessage = (e) => {\n    messages.client1.push(e.data);\n  };\n  client2.onmessage = (e) => {\n    messages.client2.push(e.data);\n  };\n\n  server.send('hello everyone');\n  expect(messages).toEqual({\n    client1: ['hello everyone'],\n    client2: ['hello everyone'],\n  });\n});\n```\n\n### JSON protocols support\n\n`vitest-websocket-mock` can also automatically serialize and deserialize\nJSON messages:\n\n```js\ntest('the mock server seamlessly handles JSON protocols', async () => {\n  const server = new WS('ws://localhost:1234', { jsonProtocol: true });\n  const client = new WebSocket('ws://localhost:1234');\n\n  await server.connected;\n  client.send(`{ \"type\": \"GREETING\", \"payload\": \"hello\" }`);\n  await expect(server).toReceiveMessage({ type: 'GREETING', payload: 'hello' });\n  expect(server).toHaveReceivedMessages([{ type: 'GREETING', payload: 'hello' }]);\n\n  let message = null;\n  client.onmessage = (e) => {\n    message = e.data;\n  };\n\n  server.send({ type: 'CHITCHAT', payload: 'Nice weather today' });\n  expect(message).toEqual(`{\"type\":\"CHITCHAT\",\"payload\":\"Nice weather today\"}`);\n});\n```\n\n### verifyClient server option\n\nA `verifyClient` function can be given in the options for the `vitest-websocket-mock` constructor.\nThis can be used to test behaviour for a client that connects to a WebSocket server it's blacklisted from for example.\n\n**Note** : _Currently `mock-socket`'s implementation does not send any parameters to this function (unlike the real `ws` implementation)._\n\n```js\ntest('rejects connections that fail the verifyClient option', async () => {\n  new WS('ws://localhost:1234', { verifyClient: () => false });\n  const errorCallback = vi.fn();\n\n  await expect(\n    new Promise((resolve, reject) => {\n      errorCallback.mockImplementation(reject);\n      const client = new WebSocket('ws://localhost:1234');\n      client.onerror = errorCallback;\n      client.onopen = resolve;\n    })\n    // WebSocket onerror event gets called with an event of type error and not an error\n  ).rejects.toEqual(expect.objectContaining({ type: 'error' }));\n});\n```\n\n### selectProtocol server option\n\nA `selectProtocol` function can be given in the options for the `vitest-websocket-mock` constructor.\nThis can be used to test behaviour for a client that connects to a WebSocket server using the wrong protocol.\n\n```js\ntest('rejects connections that fail the selectProtocol option', async () => {\n  const selectProtocol = () => null;\n  new WS('ws://localhost:1234', { selectProtocol });\n  const errorCallback = vi.fn();\n\n  await expect(\n    new Promise((resolve, reject) => {\n      errorCallback.mockImplementationOnce(reject);\n      const client = new WebSocket('ws://localhost:1234', 'foo');\n      client.onerror = errorCallback;\n      client.onopen = resolve;\n    })\n  ).rejects.toEqual(\n    // WebSocket onerror event gets called with an event of type error and not an error\n    expect.objectContaining({\n      type: 'error',\n      currentTarget: expect.objectContaining({ protocol: 'foo' }),\n    })\n  );\n});\n```\n\n### Sending errors\n\n```js\ntest('the mock server sends errors to connected clients', async () => {\n  const server = new WS('ws://localhost:1234');\n  const client = new WebSocket('ws://localhost:1234');\n  await server.connected;\n\n  let disconnected = false;\n  let error = null;\n  client.onclose = () => {\n    disconnected = true;\n  };\n  client.onerror = (e) => {\n    error = e;\n  };\n\n  server.send('hello everyone');\n  server.error();\n  expect(disconnected).toBe(true);\n  expect(error.origin).toBe('ws://localhost:1234/');\n  expect(error.type).toBe('error');\n});\n```\n\n### Add custom event listeners\n\n#### For instance, to refuse connections:\n\n```js\nit('the server can refuse connections', async () => {\n  const server = new WS('ws://localhost:1234');\n  server.on('connection', (socket) => {\n    socket.close({ wasClean: false, code: 1003, reason: 'NOPE' });\n  });\n\n  const client = new WebSocket('ws://localhost:1234');\n  client.onclose = (event) => {\n    expect(event.code).toBe(1003);\n    expect(event.wasClean).toBe(false);\n    expect(event.reason).toBe('NOPE');\n  };\n\n  expect(client.readyState).toBe(WebSocket.CONNECTING);\n\n  await server.connected;\n  expect(client.readyState).toBe(WebSocket.CLOSING);\n\n  await server.closed;\n  expect(client.readyState).toBe(WebSocket.CLOSED);\n});\n```\n\n### Environment set up and tear down between tests\n\nYou can set up a mock server and a client, and reset them between tests:\n\n```js\nbeforeEach(async () => {\n  server = new WS('ws://localhost:1234');\n  client = new WebSocket('ws://localhost:1234');\n  await server.connected;\n});\n\nafterEach(() => {\n  WS.clean();\n});\n```\n\n## Known issues\n\n`mock-socket` has a strong usage of delays (`setTimeout` to be more specific). This means using `vi.useFakeTimers();` will cause issues such as the client appearing to never connect to the server.\n\nWhile running the websocket server from tests within the jsdom environment (as opposed to node)\nyou may see errors of the nature:\n\n```bash\n ReferenceError: setImmediate is not defined\n```\n\nYou can work around this by installing the setImmediate shim from\n[https://github.com/YuzuJS/setImmediate](https://github.com/YuzuJS/setImmediate) and\nadding `require('setimmediate');` to your `setupTests.js`.\n\n### The custom matchers are not recognized by TypeScript\n\n```\nProperty 'toReceiveMessage' does not exist on type 'Assertion<void, WS>'.\n```\n\nThe matchers are contributed with [module augmentation][augmentation], which\nonly merges into the copy of `vitest` the augmentation resolves to. Deduplicate\n`vitest` if your project resolves more than one, for example a monorepo where a\nnested package pins its own.\n\n[augmentation]: https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n\n## Testing React applications\n\nWhen testing React applications, `vitest-websocket-mock` will look for\n`@testing-library/react`'s implementation of [`act`](https://react.dev/reference/react/act).\nIf it is available, it will wrap all the necessary calls in `act`, so you don't have to.\n\nIf `@testing-library/react` is not available, we will assume that you're not testing a React application,\nand you might need to call `act` manually.\n\n## Using `vitest-websocket-mock` to interact with a non-global WebSocket object\n\n`vitest-websocket-mock` uses [Mock Socket](https://github.com/thoov/mock-socket)\nunder the hood to mock out WebSocket clients.\nOut of the box, Mock Socket will only mock out the global `WebSocket` object.\nIf you are using a third-party WebSocket client library (eg. a Node.js\nimplementation, like [`ws`](https://github.com/websockets/ws)), you'll need\nto set up a [manual mock](https://vitest.dev/api/vi.html#vi-mock):\n\n- Create a `__mocks__` folder in your project root\n- Add a new file in the `__mocks__` folder named after the library you want to\n  mock out. For instance, for the `ws` library: `__mocks__/ws.js`.\n- Export Mock Socket's implementation in-lieu of the normal export from the\n  library you want to mock out. For instance, for the `ws` library:\n\n```js\n// __mocks__/ws.js\n\nexport { WebSocket as default } from 'mock-socket';\n```\n\n- Somewhere in the test files, call `vi.mock` with the name of the library you want to mock. For instance, for the `ws` library:\n\n```js\n// foo.test.js\n\nimport WebSocket from 'ws';\nimport { vi } from 'vitest';\n\nvi.mock('ws');\n\n// do some tests...\n```\n\n**NOTE** The `ws` library is not 100% compatible with the browser API, and\nthe `mock-socket` library that `vitest-websocket-mock` uses under the hood only\nimplements the browser API.\nAs a result, `vitest-websocket-mock` will only work with the `ws` library if you\nrestrict yourself to the browser APIs!\n","readmeFilename":"README.md"}