mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-30 16:14:06 +00:00
* fix: isJson assertion fails after res.setBody() with object in node-vm
Objects created inside Node's vm.createContext() have a different Object
constructor than the host realm. When res.setBody() is called with a JS
object from a script, _.cloneDeep preserves the cross-realm prototype,
causing obj.constructor === Object to fail in the isJson assertion.
Replace with Object.prototype.toString.call() which is cross-realm safe.
* fix: register isJson chai assertion in QuickJS test runtime
The bundled chai in QuickJS only exposes { expect, assert } via
requireObject — no Assertion class. Access the prototype through
Object.getPrototypeOf(expect(null)) and use Object.defineProperty
to register the json property directly.
* fix: enable assertion chaining on isJson in QuickJS runtime
The QuickJS isJson property getter was missing `return this`, preventing
chai assertion chaining (e.g. expect(body).to.be.json.and...).
37 lines
585 B
Plaintext
37 lines
585 B
Plaintext
meta {
|
|
name: isJson after setBody
|
|
type: http
|
|
seq: 2
|
|
}
|
|
|
|
post {
|
|
url: {{host}}/api/echo/json
|
|
body: json
|
|
auth: none
|
|
}
|
|
|
|
body:json {
|
|
{
|
|
"hello": "bruno"
|
|
}
|
|
}
|
|
|
|
assert {
|
|
res.status: eq 200
|
|
res.body: isJson
|
|
}
|
|
|
|
script:post-response {
|
|
res.setBody({ id: 1, name: "updated", nested: { key: "value" } });
|
|
}
|
|
|
|
tests {
|
|
test("res.body should be json after setBody with object", function() {
|
|
const body = res.getBody();
|
|
expect(body).to.be.json;
|
|
expect(body.id).to.eql(1);
|
|
expect(body.name).to.eql("updated");
|
|
expect(body.nested.key).to.eql("value");
|
|
});
|
|
}
|