testinggospels / camouflage

Camouflage is a backend mocking tool for HTTP, gRPC, Websockets and Thrift protocols, which helps you carry out your front end prototyping, unit testing, functional/performance testing in silos, in absence of one or more Microservices/APIs.
https://testinggospels.github.io/camouflage/
MIT License
278 stars 26 forks source link

Allow json like messages for WS #114

Closed wasder closed 2 years ago

wasder commented 3 years ago

Describe the bug When I make a request to mock file below, I get an error. Allow json like messages for WebSocket. Now I have to stringify WS json message.

To Reproduce Steps to reproduce the behavior:

  1. Mock File Content ws_mocks/message.mock
    {
    "self": {
        "status": "OK",
        "result": {
            "service": {
                "abc": "123"
            }
        }
    }
    }
  2. Error Stack Trace
    
    throw new ERR_INVALID_ARG_TYPE(
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object at new NodeError (node:internal/errors:371:5) at Function.from (node:buffer:322:9) at toBuffer (/usr/local/lib/node_modules/camouflage-server/node_modules/ws/lib/buffer-util.js:97:18) at Sender.send (/usr/local/lib/node_modules/camouflage-server/node_modules/ws/lib/sender.js:265:17) at WebSocket.send (/usr/local/lib/node_modules/camouflage-server/node_modules/ws/lib/websocket.js:421:18) at Timeout._onTimeout (/usr/local/lib/node_modules/camouflage-server/dist/parser/WebsocketParser.js:61:28) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7) { code: 'ERR_INVALID_ARG_TYPE' }



**Expected behavior**
Expects above mock file to work as is.
github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 0.7.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: