Skip to content

Expand functions inside testFunctions #6

@hantuzun

Description

@hantuzun

testFunction bodies are sent directly to Postman for execution. However Postman doesn't support using custom functions or libraries out of these testFunction bodies scopes.

We may expand these functions in testFunctions. This concept is coming from lisp macros.

For example the test below should print 3 when given to jetman.execute method:

function helperA(){
    x = 1;
}

function helperB(){
    helperA();
    y = 2;
}

function testFunction(){
    helperB();
    z = x + y;
    console.log(z);
}

request =  {
    'name': 'Root endpoint works'
    'url': 'localhost:9090'
}

exports.run = function() {
    jetman.send(request, testFunction);
}

This could be achieved if the called functions in testFunction are expanded recursively beforehand. Then we can pass the following body to Postman after expansion:

    {
        {
            x = 1;
        }
        y = 2;
    }
    z = x + y;
    console.log(z);

This feature could be applied to external JS libraries too. Interest for such a feature is already expressed here: postmanlabs/newman#153

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions