Files
bruno/packages/bruno-tests/collection/asserts/test-assert-combinations.bru
Pragadesh-45 6a85635c49 Fix: Inconsistent JSON parsing and formatting in res.body and Res-preview (#4103)
* Fix: Revert selective JSON parsing where string response is not parsed

- Revert "Merge pull request #3706 from Pragadesh-45/fix/response-format-updates"
  - e897dc1eb0
- Revert "Merge pull request #3676 from pooja-bruno/fix/string-json-response"
  - 1f2bee1f90

* Fix: Revert interpreting Assert RHS-value wrapped in quotes literally

- Revert "Merge pull request #3806 from Pragadesh-45/fix/handle-assert-results"
  - 63d3cb380d
- Revert "Merge pull request #3805 from Pragadesh-45/fix/handle-assert-results"
  - 6abd063749

* Fix: Inconsistent JSON formatting in preview when encoded value is a string

* Fix: Prettify JSON for Res-preview without parsing to avoid JS specific roundings

* Fix(testbench): req.body is always Buffer after the binary req body related changes

* Added `/api/echo/custom` where response can be configured using request itself

* Added tests for validating Assert and Response-preview

Co-authored-by: Pragadesh-45 <temporaryg7904@gmail.com>

* Handle char-encoding in Response-preview and added more tests

* Updated API endpoint in tests to use httpfaker api

* QuickJS (Safe Mode) exec logic to handle template literals similar to Developer Mode

* Safe Mode bru.runRequest to return statusText similar to Developer Mode

---------

Co-authored-by: ramki-bruno <ramki@usebruno.com>
Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
2025-03-13 00:49:57 +05:30

75 lines
2.2 KiB
Plaintext

meta {
name: test-assert-combinations
type: http
seq: 1
}
post {
url: {{httpfaker}}/api/echo/custom
body: json
auth: none
}
body:json {
{
"type": "application/json",
"contentJSON": {
"string": "foo",
"stringWithSQuotes": "'foo'",
"stringWithDQuotes": "\"foo\"",
"number": 123,
"numberAsString": "123",
"numberAsStringWithSQuotes": "'123'",
"numberAsStringWithDQuotes": "\"123\"",
"numberAsStringWithLeadingZero": "0123",
"numberBig": 9007199254740992000,
"numberBigAsString": "9007199254740991999",
"null": null,
"nullAsString": "null",
"nullAsStringWithSQuotes": "'null'",
"nullAsStringWithDQuotes": "\"null\"",
"true": true,
"trueAsString": "true",
"trueAsStringWithSQuotes": "'true'",
"trueAsStringWithDQuotes": "\"true\"",
"false": false,
"falseAsString": "false",
"falseAsStringWithSQuotes": "'false'",
"falseAsStringWithDQuotes": "\"false\"",
"stringWithCurlyBraces": "{foo}",
"stringWithDoubleCurlyBraces": "{{foobar}}"
}
}
}
assert {
res.body.string: eq foo
res.body.string: eq 'foo'
res.body.string: eq "foo"
res.body.stringWithSQuotes: eq "'foo'"
res.body.stringWithDQuotes: eq '"foo"'
res.body.number: eq 123
res.body.numberAsString: eq '123'
res.body.numberAsString: eq "123"
res.body.numberAsStringWithSQuotes: eq "'123'"
res.body.numberAsStringWithDQuotes: eq '"123"'
res.body.numberAsStringWithLeadingZero: eq "0123"
res.body.numberBig.toString(): eq '9007199254740992000'
res.body.numberBigAsString: eq "9007199254740991999"
res.body.null: eq null
res.body.nullAsString: eq "null"
res.body.nullAsStringWithSQuotes: eq "'null'"
res.body.nullAsStringWithDQuotes: eq '"null"'
res.body.true: eq true
res.body.trueAsString: eq "true"
res.body.trueAsStringWithSQuotes: eq "'true'"
res.body.trueAsStringWithDQuotes: eq '"true"'
res.body.false: eq false
res.body.falseAsString: eq "false"
res.body.falseAsStringWithSQuotes: eq "'false'"
res.body.falseAsStringWithDQuotes: eq '"false"'
res.body.nonexistent: eq undefined
res.body.stringWithCurlyBraces: eq "{foo}"
res.body.stringWithDoubleCurlyBraces: eq "{{foobar}}"
}