From ed51f304b89e75aeb25716e41258b0008ba19b9f Mon Sep 17 00:00:00 2001 From: Bijin A B Date: Thu, 15 Jan 2026 13:35:42 +0530 Subject: [PATCH] fix: variables set via setVar should be interpolated only during runtime --- packages/bruno-js/src/bru.js | 2 +- packages/bruno-js/tests/runtime.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/bruno-js/src/bru.js b/packages/bruno-js/src/bru.js index 27c00da33..d0cdbbbda 100644 --- a/packages/bruno-js/src/bru.js +++ b/packages/bruno-js/src/bru.js @@ -230,7 +230,7 @@ class Bru { ); } - this.runtimeVariables[key] = this.interpolate(value); + this.runtimeVariables[key] = value; } getVar(key) { diff --git a/packages/bruno-js/tests/runtime.spec.js b/packages/bruno-js/tests/runtime.spec.js index 352be604f..797e30598 100644 --- a/packages/bruno-js/tests/runtime.spec.js +++ b/packages/bruno-js/tests/runtime.spec.js @@ -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}}'); }); }); });