diff --git a/README.md b/README.md index 367b33cfc..280d4f1bf 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ runner.run(collection, { // Globals (a "VariableScope" from the SDK) globals: new sdk.VariableScope(), + // Locals (a "variableScope" from the SDK) local variables will be initialised by this. + locals: new sdk.VariableScope(), + // Execute a folder/request using id/name or path entrypoint: { // execute a folder/request using id or name diff --git a/test/integration/inherited-entities/pm-variables.test.js b/test/integration/inherited-entities/pm-variables.test.js index e66cca8c9..9c6416731 100644 --- a/test/integration/inherited-entities/pm-variables.test.js +++ b/test/integration/inherited-entities/pm-variables.test.js @@ -4,6 +4,12 @@ var _ = require('lodash'), describe('pm.variables', function () { var testRun, runOptions = { + locals: { + values: [ + { key: 'key-1', value: 'local-value-1', name: 'key-1', enabled: true }, + { key: 'key-7', value: 'local-value-7', name: 'key-7', enabled: true } + ] + }, data: [{ 'key-4': 'data-value-4' }], @@ -95,10 +101,11 @@ describe('pm.variables', function () { consoleLogs.forEach(function (consoleLog) { expect(consoleLog).to.eql({ - 'key-1': 'global-value-1', + 'key-1': 'local-value-1', 'key-2': 'coll-value-2', 'key-3': 'env-value-3', 'key-4': 'data-value-4', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' }); @@ -107,14 +114,14 @@ describe('pm.variables', function () { it('should be honoured in request URL', function () { var url = testRun.request.getCall(0).args[3].url.toString(), - expectedParam = 'global-value-1:coll-value-2:env-value-3:data-value-4:global-value-5'; + expectedParam = 'local-value-1:coll-value-2:env-value-3:data-value-4:global-value-5'; expect(url).to.equal('https://postman-echo.com/get?param=' + expectedParam); }); it('should be honoured in auth', function () { var response = testRun.response.getCall(0).args[2], - expectedToken = 'global-value-1:coll-value-2:env-value-3:data-value-4:global-value-5'; + expectedToken = 'local-value-1:coll-value-2:env-value-3:data-value-4:global-value-5'; expect(response.json()).to.deep.nested.include({ 'headers.authorization': 'Bearer ' + expectedToken @@ -234,6 +241,7 @@ describe('pm.variables', function () { 'key-2': 'modified-1', 'key-3': 'env-value-3', 'key-4': 'data-value-4', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' } @@ -246,6 +254,7 @@ describe('pm.variables', function () { 'key-2': 'modified-2', 'key-3': 'modified-2', 'key-4': 'data-value-4', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' } @@ -258,6 +267,7 @@ describe('pm.variables', function () { 'key-2': 'modified-2', 'key-3': 'modified-3', 'key-4': 'modified-3', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' } @@ -270,6 +280,7 @@ describe('pm.variables', function () { 'key-2': 'modified-2', 'key-3': 'modified-3', 'key-4': 'modified-4', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' } @@ -282,6 +293,7 @@ describe('pm.variables', function () { 'key-2': 'modified-1', 'key-3': 'modified-3', 'key-4': 'modified-4', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' } @@ -294,6 +306,7 @@ describe('pm.variables', function () { 'key-2': 'modified-1', 'key-3': 'modified-3', 'key-4': 'modified-3', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' } @@ -361,6 +374,7 @@ describe('pm.variables', function () { 'key-2': 'coll-value-2', 'key-3': 'env-value-3', 'key-4': 'data-value-4', + 'key-7': 'local-value-7', 'vault:key5': 'global-value-5', 'vault:key6': 'vault-value-6' }