Skip to content

Latest commit

 

History

History
79 lines (43 loc) · 2.84 KB

File metadata and controls

79 lines (43 loc) · 2.84 KB

Postman: What you need to know for your project

Getting Started

Free Online HTTP Test Services (to play around)

Import a Test Collection

  1. File > Import ...

    Postman import

  2. Choose file tests/server.postman_collection.json

    Postman choose file

Run a Test Collection

  1. Create a new empty environment in Postman in the top right corner via Add

    Postman new environment

  2. Start your backend server in the terminal via npm run dev

  3. Run the collection

    Postman run collection

  4. Select your empty environment and click Run server

    Postman collection runner

Export Test Collection

  1. In the extended menu ... of your collection, click Export

    Postman export button

  2. Choose the latest export format (v2.1)

    Postman export format

  3. Overwrite the file tests/server.postman_collection.json

    Postman overwrite file

  4. Run npm test in your terminal

    Postman run tests

Test script assertions

Chaining Requests via Postman Variables

Make sure your test collection works on an empty database!

Whenever you create an object that you want to use later (e.g., to retrieve, update, delete), you need to save its _id to a Postman environment variable for later re-use:

  1. Save the _id of created objects for later request via pm.environment.set("camel_id", jsonData._id);

    Postman save id

  2. Use variables in later requests in Postman via {{camel_id}} or in Postman scripts or via pm.variables.get("camel_id");

    Postman use variable

Check out the following documentation for more info: