Files
bruno/packages/bruno-tests/collection/scripting/api/bru/interpolate.bru
sanish chirayath 9a35302d4b Feature: implemented bru.interpolate (#4122)
* feat: enhance variable highlighting in CodeMirror and update interpolation method

* feat: add interpolate function to bru shim and corresponding tests

- Implemented the `interpolate` function in the bru shim to handle variable interpolation.
- Added a new test case for the `interpolate` function to verify its functionality with mock variables.

* feat: enhance interpolate function to support object interpolation

* feat: add translation support for pm.variables.replaceIn to bru.interpolate

* revert: eslint config changes

* revert: eslint config changes

* fix: update method call to use correct interpolation function in Bru class

* refactor: added jsdoc to codemirror highlighting code

* fix: higlighting for multiline editor
2025-05-22 15:37:15 +05:30

40 lines
901 B
Plaintext

meta {
name: interpolate
type: http
seq: 13
}
get {
url: {{host}}/ping
body: none
auth: none
}
tests {
test("should interpolate envs", function() {
const interpolated = bru.interpolate("url: {{host}}")
expect(interpolated).to.equal("url: https://testbench-sanity.usebruno.com");
});
test("should interpolate random variables", function() {
const a = bru.interpolate("{{$randomInt}}")
const b = bru.interpolate("{{$randomInt}}")
expect(a).to.not.equal(b)
});
const randomObj = {
host: "{{host}}",
int: "{{$randomInt}}",
timestamp: "{{$timestamp}}"
}
test("should interpolate objects with vars, random vars", function() {
const objA = bru.interpolate(randomObj)
const objB = bru.interpolate(randomObj)
expect(objA).to.be.an("object")
expect(objB).to.be.an("object")
expect(objA).to.not.deep.eql(objB)
});
}