For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Postman
PricingEnterprise
Contact SalesSign InSign Up for Free
HomeDocs
HomeDocs
      • Overview
        • Overview
        • Write pre-request scripts
        • Write tests
        • Script examples
        • Dynamic variables
        • Troubleshoot test errors
Postman API Platform

Product

  • Postman Overview
  • Enterprise
  • Spec Hub
  • Flows
  • Agent Mode
  • API Catalog
  • Fern
  • Postman CLI
  • Integrations
  • Workspaces
  • Plans and pricing

API Network

  • App Security
  • Artificial Intelligence
  • Communication
  • Data Analytics
  • Database
  • Developer Productivity
  • DevOps
  • Ecommerce
  • eSignature
  • Financial Services
  • Payments
  • Travel

Resources

  • Postman Docs
  • Academy
  • Community
  • Templates
  • Intergalactic
  • Videos
  • MCP Servers

Legal and Security

  • Legal Terms Hub
  • Terms of Service
  • Postman Product Terms
  • Security
  • Website Terms of Use

Company

  • About
  • Careers and culture
  • Contact us
  • Partner program
  • Customer stories
  • Student programs
  • Press and media
Twitter iconLinkedIn iconGithub iconYouTube iconInstagram iconDiscord icon
Download Postman
Privacy Policy

© 2026 Postman, Inc.

On this page
  • Use the Postman Console logs
  • Assertion deep equality error
  • Variable not defined error
  • Assertion undefined error
  • Test not failing
Tests and scriptsWrite scripts

Troubleshoot common test errors

||View as Markdown|
Was this page helpful?
Previous

Persist state across requests in local mock servers

Next

Test APIs with datasets in Postman

Built with

When you encounter errors or unexpected behavior in your post-response scripts, the Postman Console can help you to identify the source.

Use the Postman Console logs

By combining console.log(), console.info(), console.warn(), and console.error() debug statements with your test assertions, you can examine the content of the HTTP requests and responses, and Postman data items such as variables. You can also use the console.clear() method to clear information from the console. Select Console icon Console from the Postman footer to open it.

Console info

Log the value of a variable or response property:

1console.log(pm.collectionVariables.get("name"));
2console.log(pm.response.json().name);

Log the type of variable or response property:

1console.log(typeof pm.response.json().id);

Use Console logs to mark code execution, sometimes known as “trace statements”:

1if (pm.response.json().id) {
2 console.log("id was found!");
3 // do something
4} else {
5 console.log("no id ...");
6 //do something else
7}

Assertion deep equality error

You might encounter the AssertionError: expected <value> to deeply equal '<value>' error. For example, this would arise with the following code:

1pm.expect(1).to.eql("1");

This happens because the test is comparing a number to a string value. The test will only return true if both the type and value are equal.

Variable not defined error

You might encounter the ReferenceError: <variable> is not defined error. This typically happens when you’re attempting to reference a variable that hasn’t been declared or is outside the scope of your test code.

In the following example, a JSON object is the value of a variable in the first test. The second test is attempting to reference the variable, but it can’t because the variable is outside the scope of the second test’s code.

1/* Response has the following structure:
2{
3 "name": "John",
4 "age": 29
5},
6*/
7pm.test("Test 1", () => {
8 const jsonData = pm.response.json();
9 pm.expect(jsonData.name).to.eql("John");
10});
11
12pm.test("Test 2", () => {
13 pm.expect(jsonData.age).to.eql(29); // ReferenceError: jsonData is not defined
14});

Make sure variables are available at the global scope if test functions needs to reference it. In the previous example, moving const jsonData = pm.response.json(); before the first pm.test would make it available to both test functions.

Assertion undefined error

You might encounter the AssertionError: expected undefined to deeply equal <value> error. Typically this happens when you are referring to a property that doesn’t exist or is out of scope.

1const jsonData = pm.response.json();
2pm.expect(jsonData.name).to.eql("John");

In this example, if you get the error AssertionError: expected undefined to deeply equal 'John', this indicates that the name property isn’t defined in the jsonData object.

Test not failing

There may be occasions where you expect a test to fail, and it doesn’t. Make sure your test code is syntactically correct, then resend your request.

In the following example, the test is expected to fail because true doesn’t equal false. The test actually passes because the pm.test function isn’t correctly defined. The pm.test function is missing the first parameter, which is a text string that displays in the test result output. You can learn more about defining tests using the pm.test function.

1pm.test( function () {
2 pm.expect(true).to.eql(false);
3});