Intro to Writing Tests

Number of APIs: 6

About this collection

Qodex's powerful scripting feature helps you to write a range of API tests in JavaScript, including integration, regression, and contract tests.

Using the collection

Step 1: Send the sample requests and view the response and test results.

Step 2: Replace the sample request URLs with your desired API endpoints.

Step 3: Customize the tests in the Tests tab if needed. Don't forget to save your changes.

Quick tips for writing tests

  • Organize your test scenarios by grouping your requests in collections and folders, and naming them descriptively
  • Document your API’s requirements using markdown in the descriptions
  • Use variables to simulate more sophisticated user flows
  • Common tests that will be run after every request can be added to collection-level tests or folder-level tests

Resources

Test scripts

Test examples

Quick reference guide

Examples and guides

Writing tests in Qodex

API testing tips from a Qodex professional

  1. Basic test syntax - pm.expect and pm.response GET https://postman-echo.com/get?foo1=bar1&foo2=bar2

  2. API tests - Performance PUT https://postman-echo.com/put

  3. API tests - Data type PATCH https://postman-echo.com/patch

  4. API tests - Functional2 DELETE https://postman-echo.com/delete

  5. API tests - JSON schema v4 validation GET https://postman-echo.com/get?foo1=bar1&foo2=bar2

  6. API tests - SQL injection security check POST https://postman-echo.com/post