Keyboard Shortcuts
- Ctrl/Cmd + EnterSend request
- Ctrl/Cmd + SSave request
- Ctrl/Cmd + NNew tab
- Ctrl/Cmd + WClose tab
- Ctrl/Cmd + /Toggle sidebar
- Ctrl/Cmd + BToggle sidebar
Variable Syntax
- {{variable}}Use variable
- {{$guid}}Random UUID
- {{$timestamp}}Unix timestamp
- {{$randomInt}}Random integer
- {{$randomEmail}}Random email
Variable Scopes
- GlobalAll workspaces
- CollectionWithin collection
- EnvironmentPer environment
- DataFrom data file
- LocalSingle request
pm Object
- pm.responseResponse object
- pm.requestRequest object
- pm.environmentEnvironment vars
- pm.globalsGlobal vars
- pm.collectionVariablesCollection vars
Pre-request Script Examples
// Set variable
pm.environment.set("token", "abc123");
// Get variable
const baseUrl = pm.environment.get("baseUrl");
// Generate timestamp
pm.environment.set("timestamp", Date.now());
// Generate random number
pm.environment.set("randomId", Math.floor(Math.random() * 1000));
Test Script Examples
// Status code check
pm.test("Status code is 200", function() {
pm.response.to.have.status(200);
});
// Response time check
pm.test("Response time < 500ms", function() {
pm.expect(pm.response.responseTime).to.be.below(500);
});
// JSON body check
pm.test("Has user id", function() {
const jsonData = pm.response.json();
pm.expect(jsonData.id).to.exist;
});
Chai Assertions
- pm.expect(x).to.equal(y)Equality
- pm.expect(x).to.be.trueBoolean check
- pm.expect(x).to.existExists check
- pm.expect(x).to.include(y)Contains
- pm.expect(x).to.be.an("array")Type check
Response Checks
- pm.response.json()Parse JSON
- pm.response.text()Get text
- pm.response.codeStatus code
- pm.response.responseTimeResponse time
- pm.response.headersHeaders object
Newman CLI Commands
# Run collection
newman run collection.json
# With environment
newman run collection.json -e environment.json
# With data file (CSV/JSON)
newman run collection.json -d data.csv
# Generate HTML report
newman run collection.json -r htmlextra
# Run specific folder
newman run collection.json --folder "API Tests"
# Set iterations
newman run collection.json -n 10
Dynamic Variables
- {{$randomFirstName}}Random name
- {{$randomLastName}}Random surname
- {{$randomCity}}Random city
- {{$randomPhoneNumber}}Random phone
- {{$randomLoremWord}}Lorem word
Collection Runner
- IterationsRun multiple times
- DelayBetween requests
- Data fileCSV/JSON input
- Keep variablesPersist values