usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
26.87k stars 1.23k forks source link

isJson assertion returns the error "Invalid Chai property" #132

Closed dcoomber closed 1 year ago

dcoomber commented 1 year ago

Description

isJson assertion returns the error Invalid Chai property: json. Did you mean "to"?

Test collection

Test collection: https://github.com/dcoomber/exploring-bruno/tree/dpc_session_1/exploration/02-create/EE%20Bookings

Test request: "Retrieve a booking"

Screenshot

Screenshot 2023-03-18 at 11 54 53
helloanoop commented 1 year ago

Thanks for catching this @dcoomber !

Would you be able to work on fixing this? The code is here

dcoomber commented 1 year ago

I have ended up proposing the use of https://github.com/chaijs/chai-http, but am uncertain if this is what you're looking for. chai-http .to.be.json is merely a check that the response headers includes Content-Type: application/json. In this form, the assertion would only ever be valid when comparing against res and would not be usable for comparisons of subsets of the response structure.

Please let me know if you had a different solution in mind.

dcoomber commented 1 year ago

After reviewing https://www.chaijs.com/api/plugins/ along with stepping through some of the other assertions, I realised that we're looking to addProperty and not addMethod.

PR updated.