Newman sandbox "There was an error in evaluating the test script" in CI
Newman ran a pre-request or test script inside its sandbox and the JavaScript threw. A ReferenceError or reading a property of undefined stops the script, and Newman reports the sandbox evaluation error for that request.
What this error means
Newman prints "There was an error in evaluating the test script" or a ReferenceError under a request, and the assertions in that script do not run.
POST Create order
There was an error in evaluating the test script:
ReferenceError: pmResponse is not defined
inside "Create order"Common causes
A typo or undefined variable in the script
The script references a name that does not exist (a typo for pm.response, or a variable set on a prior request that did not run), throwing a ReferenceError.
Reading a property before the response parsed
The script calls pm.response.json() on a non-JSON body or reads a field of an undefined object, throwing a TypeError inside the sandbox.
How to fix it
Fix the script reference and guard undefined
- Read the error to find the exact undefined name or property.
- Correct the reference (use
pm.response,pm.environment.get(...)). - Guard optional fields before reading them so the sandbox does not throw.
pm.test("has order id", function () {
const body = pm.response.json();
pm.expect(body).to.have.property("id");
});Run one request in isolation to debug
Use a folder or a single request with --verbose to see the failing script in isolation before the full run.
newman run collection.json --folder "Create order" --verboseHow to prevent it
- Reference Postman sandbox objects by their exact names (
pm.response,pm.environment). - Guard optional response fields before reading them.
- Keep scripts small and test them with a single-folder run.