fix: variables set via setVar should be interpolated only during runtime

This commit is contained in:
Bijin A B
2026-01-15 13:35:42 +05:30
parent b1e6a707bf
commit ed51f304b8
2 changed files with 3 additions and 3 deletions

View File

@@ -230,7 +230,7 @@ class Bru {
);
}
this.runtimeVariables[key] = this.interpolate(value);
this.runtimeVariables[key] = value;
}
getVar(key) {

View File

@@ -248,14 +248,14 @@ describe('runtime', () => {
});
describe('bru.setVar random variable', () => {
it('should not be equal to {{$randomFirstName}}', async () => {
it('should be able to set random variables as values', async () => {
const script = `bru.setVar('title', '{{$randomFirstName}}')`;
const runtime = new ScriptRuntime({ runtime: 'nodevm' });
const result = await runtime.runRequestScript(script, {}, {}, {}, '.', null, process.env);
expect(result.runtimeVariables.title).not.toBe('{{$randomFirstName}}');
expect(result.runtimeVariables.title).toBe('{{$randomFirstName}}');
});
});
});