AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
222 stars 20 forks source link

Assert with floating point number fails #283

Closed bohni closed 1 month ago

bohni commented 1 month ago
POST https://httpbin.org/post
Content-Type: application/json

{
  "someFields": [
    {
      "confidence": 1
    },
    {
      "confidence": 0.934
    }
  ]
}

?? js response.parsedBody.json.someFields[0].confidence == 1
?? js response.parsedBody.json.someFields[1].confidence == 0.934

Assert:

?? js response.parsedBody.signatures[1].confidence == 0.934

This assert fails with message

response.parsedBody.signatures[1].confidence == 0.934 (AssertionError [ERR_ASSERTION]: response.parsedBody.signatures[1].confidence (0.934) == 0 - <path>

AnWeber commented 1 month ago

I have to convert the string into a number before the comparison, unfortunately I used parseInt there. With the next release, parseFloat will now be used