bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Test translation on import doesn't properly convert 'pm.response.code'

Open DanaEpp opened this issue 1 year ago • 1 comments

Issue

During import of a Postman collection with existing tests, Bruno attempts to import the tests and translate them into BRU.

It appears it misses pm.response.code. It should be converted to res.status. As a result, all tests will fail as the pm object is "rightfully" not defined.

image

Original Postman Test

pm.test("Get valid access token", function () {
    if( pm.response.code === 200 ) {
        var jsonData = pm.response.json();
        pm.collectionVariables.set("validToken", jsonData.token);
    }
});

Translated Bruno Test

test("Get valid access token", function () {
    if( pm.response.code === 200 ) {
        var jsonData = pm.response.json();
        bru.setVar("validToken", jsonData.token);
    }
});

Expected Bruno Test

test("Get valid access token", function () {
    if( res.status === 200 ) {
        var jsonData = res.getBody();
        bru.setVar("validToken", jsonData.token);
    }
});

DanaEpp avatar Apr 02 '24 23:04 DanaEpp

I also notice that it didn't convert pm.response.json() to res.getBody()

DanaEpp avatar Apr 03 '24 00:04 DanaEpp