@astrofoundry/pi-astro 0.2.12 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/grimoire/SKILL.md +101 -0
- package/skills/playwright-cli/SKILL.md +278 -0
- package/skills/playwright-cli/references/request-mocking.md +87 -0
- package/skills/playwright-cli/references/running-code.md +232 -0
- package/skills/playwright-cli/references/session-management.md +169 -0
- package/skills/playwright-cli/references/storage-state.md +275 -0
- package/skills/playwright-cli/references/test-generation.md +88 -0
- package/skills/playwright-cli/references/tracing.md +139 -0
- package/skills/playwright-cli/references/video-recording.md +43 -0
- package/skills/postman-cli/SKILL.md +339 -0
- package/skills/postman-cli/references/environments.md +92 -0
- package/skills/postman-cli/references/reporters.md +94 -0
- package/skills/postman-cli/references/request-scripting.md +69 -0
- package/skills/raycast-script-creator/SKILL.md +132 -0
- package/themes/astro.json +76 -0
- package/skills/.gitkeep +0 -0
- package/themes/.gitkeep +0 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: postman-cli
|
|
3
|
+
description: Runs Postman collections, sends HTTP requests, manages mock servers, lints API specs, and pushes workspace changes from the command line. Use this skill whenever the user wants to run API tests, execute collection runs, send ad-hoc HTTP requests, test endpoints, check if an API is working, hit a URL, run Postman tests against QA or staging, start mock servers, lint OpenAPI specs, manage Postman workspace sync, or do anything curl-like with environment variables and auth. Trigger even when the user says "test my API", "call this endpoint", "run the collection", or "send a request to..." — this skill replaces curl/wget with Postman's full feature set.
|
|
4
|
+
allowed-tools: Bash(postman:*)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Postman CLI
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# run a collection locally with an environment
|
|
13
|
+
postman collection run ./postman/collections/nada-to-odoo -e ./postman/environments/qa.postman_environment.yaml
|
|
14
|
+
# run a specific folder within a collection
|
|
15
|
+
postman collection run ./postman/collections/nada-to-odoo -i "sale.order"
|
|
16
|
+
# send a quick GET request
|
|
17
|
+
postman request https://api.example.com/health
|
|
18
|
+
# send a POST with body and auth
|
|
19
|
+
postman request POST https://api.example.com/orders --body '{"item":"test"}' --auth-bearer-token "$TOKEN"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
### Collection run
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# run entire collection from local path
|
|
28
|
+
postman collection run <collectionPath> [options]
|
|
29
|
+
|
|
30
|
+
# run with environment file
|
|
31
|
+
postman collection run ./collection -e ./env.yaml
|
|
32
|
+
|
|
33
|
+
# run with environment variable overrides
|
|
34
|
+
postman collection run ./collection -e ./env.yaml --env-var "odoo_base_url=https://odoo.example.com" --env-var "odoo_db=test_db"
|
|
35
|
+
|
|
36
|
+
# run with global variables
|
|
37
|
+
postman collection run ./collection -g ./globals.json
|
|
38
|
+
postman collection run ./collection --global-var "api_version=v2"
|
|
39
|
+
|
|
40
|
+
# run specific folder(s) or request(s) by name or ID
|
|
41
|
+
postman collection run ./collection -i "sale.order"
|
|
42
|
+
postman collection run ./collection -i "sale.order" -i "res.partner"
|
|
43
|
+
|
|
44
|
+
# run with iteration data file (JSON or CSV)
|
|
45
|
+
postman collection run ./collection -d ./test-data.csv -n 5
|
|
46
|
+
|
|
47
|
+
# stop on first error
|
|
48
|
+
postman collection run ./collection --bail
|
|
49
|
+
postman collection run ./collection --bail --failure
|
|
50
|
+
|
|
51
|
+
# control timeouts (milliseconds)
|
|
52
|
+
postman collection run ./collection --timeout 60000 --timeout-request 10000 --timeout-script 5000
|
|
53
|
+
|
|
54
|
+
# add delay between requests
|
|
55
|
+
postman collection run ./collection --delay-request 500
|
|
56
|
+
|
|
57
|
+
# verbose output
|
|
58
|
+
postman collection run ./collection --verbose
|
|
59
|
+
|
|
60
|
+
# suppress exit code (always exit 0)
|
|
61
|
+
postman collection run ./collection -x
|
|
62
|
+
|
|
63
|
+
# use custom working directory for relative file paths
|
|
64
|
+
postman collection run ./collection --working-dir ./postman
|
|
65
|
+
|
|
66
|
+
# ignore redirects
|
|
67
|
+
postman collection run ./collection --ignore-redirects
|
|
68
|
+
|
|
69
|
+
# SSL options
|
|
70
|
+
postman collection run ./collection -k
|
|
71
|
+
postman collection run ./collection --ssl-client-cert ./cert.pem --ssl-client-key ./key.pem
|
|
72
|
+
postman collection run ./collection --ssl-extra-ca-certs ./ca.pem
|
|
73
|
+
|
|
74
|
+
# cookie jar
|
|
75
|
+
postman collection run ./collection --cookie-jar ./cookies.json --export-cookie-jar ./cookies-after.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Reporters
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# default: CLI reporter only
|
|
82
|
+
postman collection run ./collection
|
|
83
|
+
|
|
84
|
+
# JSON report
|
|
85
|
+
postman collection run ./collection -r json
|
|
86
|
+
|
|
87
|
+
# multiple reporters
|
|
88
|
+
postman collection run ./collection -r cli,json,junit,html
|
|
89
|
+
|
|
90
|
+
# custom export path
|
|
91
|
+
postman collection run ./collection -r json --reporter-json-export ./reports/result.json
|
|
92
|
+
postman collection run ./collection -r junit --reporter-junit-export ./reports/result.xml
|
|
93
|
+
postman collection run ./collection -r html --reporter-html-export ./reports/result.html
|
|
94
|
+
|
|
95
|
+
# newman-compatible JSON structure
|
|
96
|
+
postman collection run ./collection -r json --reporter-json-structure newman
|
|
97
|
+
|
|
98
|
+
# omit sensitive data from reports
|
|
99
|
+
postman collection run ./collection -r json --reporter-json-omitRequestBodies --reporter-json-omitResponseBodies
|
|
100
|
+
postman collection run ./collection -r json --reporter-json-omitHeaders
|
|
101
|
+
postman collection run ./collection -r json --reporter-json-omitAllHeadersAndBody
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Reports are saved to `./postman-cli-reports/` by default. Only the CLI reporter is supported for v3 format (YAML) collections. JSON, JUnit, and HTML reporters require v2 format (JSON) collections.
|
|
105
|
+
|
|
106
|
+
### Send a single request
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# basic GET
|
|
110
|
+
postman request https://api.example.com/users
|
|
111
|
+
|
|
112
|
+
# explicit method
|
|
113
|
+
postman request GET https://api.example.com/users
|
|
114
|
+
postman request POST https://api.example.com/users
|
|
115
|
+
postman request PUT https://api.example.com/users/1
|
|
116
|
+
postman request PATCH https://api.example.com/users/1
|
|
117
|
+
postman request DELETE https://api.example.com/users/1
|
|
118
|
+
|
|
119
|
+
# with headers
|
|
120
|
+
postman request https://api.example.com/data -H "Content-Type:application/json" -H "X-API-Key:abc123"
|
|
121
|
+
|
|
122
|
+
# with body (inline, from file, or from stdin)
|
|
123
|
+
postman request POST https://api.example.com/users --body '{"name":"John"}'
|
|
124
|
+
postman request POST https://api.example.com/users --body @data.json
|
|
125
|
+
echo '{"name":"John"}' | postman request POST https://api.example.com/users --body -
|
|
126
|
+
|
|
127
|
+
# multipart form data
|
|
128
|
+
postman request POST https://api.example.com/upload -f "name=John" -f "avatar=@photo.jpg"
|
|
129
|
+
|
|
130
|
+
# with environment file (resolves {{variables}} in URL, headers, body)
|
|
131
|
+
postman request POST https://{{base_url}}/api/users -e dev.postman_environment.json --body '{"name":"{{test_user}}"}'
|
|
132
|
+
|
|
133
|
+
# authentication
|
|
134
|
+
postman request https://api.example.com/data --auth-bearer-token "mytoken123"
|
|
135
|
+
postman request https://api.example.com/data --auth-basic-username user --auth-basic-password pass
|
|
136
|
+
postman request https://api.example.com/data --auth-apikey-key "X-API-Key" --auth-apikey-value "abc123" --auth-apikey-in header
|
|
137
|
+
|
|
138
|
+
# with pre-request and post-response scripts
|
|
139
|
+
postman request POST https://api.example.com/login --body '{"user":"admin","pass":"secret"}' \
|
|
140
|
+
--script-post-request "const token = pm.response.json().token; console.log('Token:', token);"
|
|
141
|
+
|
|
142
|
+
# timeout and retries
|
|
143
|
+
postman request https://api.example.com/health --timeout 5000 --retry 3 --retry-delay 1000
|
|
144
|
+
|
|
145
|
+
# redirect control
|
|
146
|
+
postman request https://api.example.com/redirect --redirects-ignore
|
|
147
|
+
postman request https://api.example.com/redirect --redirects-max 5
|
|
148
|
+
|
|
149
|
+
# output control
|
|
150
|
+
postman request https://api.example.com/data --response-only
|
|
151
|
+
postman request https://api.example.com/data --verbose
|
|
152
|
+
postman request https://api.example.com/data --debug
|
|
153
|
+
postman request https://api.example.com/data --output response.json
|
|
154
|
+
|
|
155
|
+
# pipe response to other tools
|
|
156
|
+
postman request https://api.example.com/data --response-only | jq '.results[]'
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Authentication
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# sign in via browser
|
|
163
|
+
postman login
|
|
164
|
+
|
|
165
|
+
# sign in with API key (for CI/CD)
|
|
166
|
+
postman login --with-api-key ABCD-1234-1234-1234-1234-1234
|
|
167
|
+
|
|
168
|
+
# EU data residency
|
|
169
|
+
postman login --with-api-key ABCD-1234-1234-1234-1234-1234 --region eu
|
|
170
|
+
|
|
171
|
+
# sign out
|
|
172
|
+
postman logout
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Collection migration
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# migrate v2.1 (JSON) collection to v3 (YAML) format
|
|
179
|
+
postman collection migrate ./my-collection.json
|
|
180
|
+
postman collection migrate ./my-collection.json --output ./path/to/new-collection
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Mock servers
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# start a local mock server from a manifest file
|
|
187
|
+
postman mock run ./mock-manifest.json
|
|
188
|
+
|
|
189
|
+
# start mock in background, run collection against it, then stop
|
|
190
|
+
postman mock run ./postman/mocks/odoo-mock.json &
|
|
191
|
+
MOCK_PID=$!
|
|
192
|
+
postman collection run ./postman/collections/nada-to-odoo \
|
|
193
|
+
-e ./postman/environments/qa.postman_environment.yaml \
|
|
194
|
+
--env-var "odoo_base_url=http://localhost:3000"
|
|
195
|
+
kill $MOCK_PID
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Spec linting
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# lint a local API specification file
|
|
202
|
+
postman spec lint ./openapi.yaml
|
|
203
|
+
postman spec lint ./openapi.json
|
|
204
|
+
|
|
205
|
+
# lint by specification ID (requires login)
|
|
206
|
+
postman spec lint 12345678-abcd-1234-abcd-1234567890ab
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Flows
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# list all flows
|
|
213
|
+
postman flows list
|
|
214
|
+
|
|
215
|
+
# run a flow from a local file
|
|
216
|
+
postman flows run ./path/to/flow.json
|
|
217
|
+
|
|
218
|
+
# deploy a flow (required before triggering)
|
|
219
|
+
postman flows deploy <flowId>
|
|
220
|
+
|
|
221
|
+
# trigger a deployed flow
|
|
222
|
+
postman flows trigger <flowId>
|
|
223
|
+
|
|
224
|
+
# update a deployed flow's settings
|
|
225
|
+
postman flows update <flowId>
|
|
226
|
+
|
|
227
|
+
# list run history
|
|
228
|
+
postman flows list-runs
|
|
229
|
+
|
|
230
|
+
# analyze a specific flow run
|
|
231
|
+
postman flows get-run
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Workspace sync
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# validate and prepare local collections/environments for push
|
|
238
|
+
postman workspace prepare
|
|
239
|
+
|
|
240
|
+
# push local changes to Postman workspace
|
|
241
|
+
postman workspace push
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Basic
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# version
|
|
248
|
+
postman --version
|
|
249
|
+
|
|
250
|
+
# help
|
|
251
|
+
postman --help
|
|
252
|
+
postman <command> --help
|
|
253
|
+
postman collection run --help
|
|
254
|
+
|
|
255
|
+
# global options (available on all commands)
|
|
256
|
+
postman --silent <command>
|
|
257
|
+
postman --color off <command>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Exit codes
|
|
261
|
+
|
|
262
|
+
- `0` — Success (all tests passed, or for `request`: 2xx-3xx response)
|
|
263
|
+
- `N` — Number of failed tests (e.g., exit code 3 means 3 tests failed)
|
|
264
|
+
- `1` — General error (invalid options, file not found, network error)
|
|
265
|
+
|
|
266
|
+
## Project-specific usage
|
|
267
|
+
|
|
268
|
+
This project stores Postman collections and environments in the `postman/` directory:
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
postman/
|
|
272
|
+
collections/
|
|
273
|
+
nada-to-odoo/ # Nada API calls to Odoo
|
|
274
|
+
delivery.carrier/
|
|
275
|
+
product.template/
|
|
276
|
+
res.partner/
|
|
277
|
+
sale.order/
|
|
278
|
+
stock.location/
|
|
279
|
+
stock.quant/
|
|
280
|
+
odoo-to-nada/ # Odoo webhook push calls to Nada
|
|
281
|
+
environments/
|
|
282
|
+
qa.postman_environment.yaml
|
|
283
|
+
flows/
|
|
284
|
+
globals/
|
|
285
|
+
mocks/
|
|
286
|
+
specs/
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Run the nada-to-odoo collection against QA
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
postman collection run ./postman/collections/nada-to-odoo \
|
|
293
|
+
-e ./postman/environments/qa.postman_environment.yaml \
|
|
294
|
+
--env-var "odoo_base_url=https://odoo-qa.drops.com" \
|
|
295
|
+
--env-var "odoo_db=drops_qa"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Run only the sale.order folder
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
postman collection run ./postman/collections/nada-to-odoo \
|
|
302
|
+
-e ./postman/environments/qa.postman_environment.yaml \
|
|
303
|
+
-i "sale.order" \
|
|
304
|
+
--env-var "odoo_base_url=https://odoo-qa.drops.com"
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Run the odoo-to-nada collection (webhook push tests)
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
postman collection run ./postman/collections/odoo-to-nada \
|
|
311
|
+
-e ./postman/environments/qa.postman_environment.yaml \
|
|
312
|
+
--env-var "nada_base_url=https://nada-qa.drops.me"
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Generate a JSON report for CI
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
postman collection run ./postman/collections/nada-to-odoo \
|
|
319
|
+
-e ./postman/environments/qa.postman_environment.yaml \
|
|
320
|
+
-r cli,json \
|
|
321
|
+
--reporter-json-export ./postman-cli-reports/nada-to-odoo.json
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Quick ad-hoc request to Odoo
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
postman request POST "https://odoo-qa.drops.com/json/2/res.partner/search_read" \
|
|
328
|
+
--auth-bearer-token "$ODOO_API_TOKEN" \
|
|
329
|
+
-H "Content-Type:application/json" \
|
|
330
|
+
-H "X-Odoo-Database:drops_qa" \
|
|
331
|
+
--body '{"domain": [["is_company","=",true]], "fields": ["name","email"], "limit": 5}' \
|
|
332
|
+
--response-only | jq .
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Specific tasks
|
|
336
|
+
|
|
337
|
+
* **Reporters and report customization** [references/reporters.md](references/reporters.md) — Read when generating CI reports, customizing output format, or omitting sensitive data from exports
|
|
338
|
+
* **Request scripting and chaining** [references/request-scripting.md](references/request-scripting.md) — Read when writing post-response scripts, chaining multiple requests, or using the pm.* API
|
|
339
|
+
* **Environment and variable management** [references/environments.md](references/environments.md) — Read when working with environment files, variable precedence, Vault secrets, or CLI overrides
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Environment and Variable Management
|
|
2
|
+
|
|
3
|
+
The Postman CLI resolves `{{variable}}` placeholders in URLs, headers, and request bodies using environment files and CLI overrides.
|
|
4
|
+
|
|
5
|
+
## Variable precedence (highest to lowest)
|
|
6
|
+
|
|
7
|
+
1. `--env-var` CLI overrides
|
|
8
|
+
2. `--global-var` CLI overrides
|
|
9
|
+
3. Environment file (`-e`)
|
|
10
|
+
4. Globals file (`-g`)
|
|
11
|
+
5. Postman Vault secrets (only available when signed in)
|
|
12
|
+
|
|
13
|
+
## Environment files
|
|
14
|
+
|
|
15
|
+
Environment files are YAML or JSON. Specify with `-e`:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
postman collection run ./collection -e ./postman/environments/qa.postman_environment.yaml
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Example environment file (YAML):
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
name: QA
|
|
25
|
+
values:
|
|
26
|
+
- key: odoo_base_url
|
|
27
|
+
value: "https://odoo-qa.drops.com"
|
|
28
|
+
enabled: true
|
|
29
|
+
description: "Base URL without trailing slash"
|
|
30
|
+
- key: odoo_db
|
|
31
|
+
value: "drops_qa"
|
|
32
|
+
enabled: true
|
|
33
|
+
- key: _odoo_partner_id
|
|
34
|
+
value: ""
|
|
35
|
+
enabled: true
|
|
36
|
+
description: "Script-managed — set after running Create Partner"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## CLI variable overrides
|
|
40
|
+
|
|
41
|
+
Override individual variables without modifying the environment file:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# override environment variables
|
|
45
|
+
postman collection run ./collection -e ./env.yaml \
|
|
46
|
+
--env-var "odoo_base_url=https://odoo-staging.drops.com" \
|
|
47
|
+
--env-var "odoo_db=drops_staging"
|
|
48
|
+
|
|
49
|
+
# override global variables
|
|
50
|
+
postman collection run ./collection \
|
|
51
|
+
--global-var "api_version=v2" \
|
|
52
|
+
--global-var "timeout=30000"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Globals files
|
|
56
|
+
|
|
57
|
+
Global variables have lower precedence than environment variables and can be overridden by them:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
postman collection run ./collection -g ./postman/globals/globals.json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Variable resolution in requests
|
|
64
|
+
|
|
65
|
+
Variables are resolved in:
|
|
66
|
+
- URLs: `{{odoo_base_url}}/json/2/sale.order/create`
|
|
67
|
+
- Headers: `Authorization: Bearer {{odoo_api_token}}`
|
|
68
|
+
- Body: `{"partner_id": {{_odoo_partner_id}}}`
|
|
69
|
+
|
|
70
|
+
## Script-managed variables
|
|
71
|
+
|
|
72
|
+
Variables prefixed with `_` are set dynamically during collection runs via scripts:
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
// in post-response script
|
|
76
|
+
pm.environment.set('_odoo_order_id', pm.response.json());
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
These are used to chain requests within a collection run (e.g., create a partner, then use the partner ID to create an order).
|
|
80
|
+
|
|
81
|
+
## Postman Vault
|
|
82
|
+
|
|
83
|
+
Secrets like `vault:odoo_api_token` and `vault:nada_x_odoo_api_key` are stored in the Postman Vault (not in environment files). They are only available when signed in to Postman. For local runs without sign-in, pass secrets via `--env-var`:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
postman collection run ./collection -e ./env.yaml \
|
|
87
|
+
--env-var "odoo_api_token=$ODOO_API_TOKEN"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Exporting variables after a run
|
|
91
|
+
|
|
92
|
+
The Postman CLI does not support exporting the final environment state after a collection run. Script-managed variables (set via `pm.environment.set()`) are only available within the scope of the current run and are not persisted to the environment file.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Reporters and Report Customization
|
|
2
|
+
|
|
3
|
+
The Postman CLI has built-in reporters to generate collection run reports. Four reporters are available: CLI, JSON, JUnit, and HTML.
|
|
4
|
+
|
|
5
|
+
**Important:** JSON, JUnit, and HTML reporters only work with v2 format (JSON) collections. v3 format (YAML) collections only support the CLI reporter.
|
|
6
|
+
|
|
7
|
+
## Available reporters
|
|
8
|
+
|
|
9
|
+
### CLI (default)
|
|
10
|
+
|
|
11
|
+
Displays a report in the terminal. Always shown unless `--silent` is used.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
postman collection run ./collection -r cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### JSON
|
|
18
|
+
|
|
19
|
+
Creates a JSON file with full run details including request/response data.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
postman collection run ./collection -r json
|
|
23
|
+
postman collection run ./collection -r json --reporter-json-export ./reports/result.json
|
|
24
|
+
|
|
25
|
+
# use Newman-compatible JSON structure
|
|
26
|
+
postman collection run ./collection -r json --reporter-json-structure newman
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### JUnit
|
|
30
|
+
|
|
31
|
+
Creates an XML file compatible with CI/CD tools that consume JUnit format.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
postman collection run ./collection -r junit
|
|
35
|
+
postman collection run ./collection -r junit --reporter-junit-export ./reports/result.xml
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### HTML
|
|
39
|
+
|
|
40
|
+
Creates an interactive HTML report. You can filter iterations by test failures or errors.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
postman collection run ./collection -r html
|
|
44
|
+
postman collection run ./collection -r html --reporter-html-export ./reports/result.html
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Multiple reporters
|
|
48
|
+
|
|
49
|
+
Combine reporters with comma-separated list:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
postman collection run ./collection -r cli,json,junit,html
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Custom export paths
|
|
56
|
+
|
|
57
|
+
By default, reports are saved to `./postman-cli-reports/` with filenames like `collection-name-yyyy-mm-dd-hh-mm-ss`. Override with:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
--reporter-json-export <path>
|
|
61
|
+
--reporter-junit-export <path>
|
|
62
|
+
--reporter-html-export <path>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
If the path is an existing directory, the report file is saved inside it. If the directory does not exist, it is created automatically.
|
|
66
|
+
|
|
67
|
+
## Omitting sensitive data
|
|
68
|
+
|
|
69
|
+
Remove request/response bodies and headers from reports:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# omit request bodies
|
|
73
|
+
--reporter-json-omitRequestBodies
|
|
74
|
+
--reporter-html-omitRequestBodies
|
|
75
|
+
|
|
76
|
+
# omit response bodies
|
|
77
|
+
--reporter-json-omitResponseBodies
|
|
78
|
+
--reporter-html-omitResponseBodies
|
|
79
|
+
|
|
80
|
+
# omit all headers
|
|
81
|
+
--reporter-json-omitHeaders
|
|
82
|
+
--reporter-html-omitHeaders
|
|
83
|
+
|
|
84
|
+
# omit everything (headers + bodies)
|
|
85
|
+
--reporter-json-omitAllHeadersAndBody
|
|
86
|
+
--reporter-html-omitAllHeadersAndBody
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## CI/CD usage
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# generate JUnit report for CI consumption, fail on test errors
|
|
93
|
+
postman collection run ./collection -r junit --reporter-junit-export ./test-results/postman.xml --bail
|
|
94
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Request Scripting and Chaining
|
|
2
|
+
|
|
3
|
+
The `postman request` command supports pre-request and post-response scripts using the Postman scripting sandbox (pm.* API).
|
|
4
|
+
|
|
5
|
+
## Post-response scripts
|
|
6
|
+
|
|
7
|
+
Use `--script-post-request` to run JavaScript after receiving the response:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# validate response
|
|
11
|
+
postman request https://api.example.com/health \
|
|
12
|
+
--script-post-request "pm.test('Health check', function() { pm.expect(pm.response.json().status).to.equal('healthy'); });"
|
|
13
|
+
|
|
14
|
+
# extract and log data
|
|
15
|
+
postman request POST https://api.example.com/login \
|
|
16
|
+
--body '{"user":"admin","pass":"secret"}' \
|
|
17
|
+
--script-post-request "const token = pm.response.json().token; console.log('Token:', token);"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Chaining requests
|
|
21
|
+
|
|
22
|
+
Use shell command substitution with `--response-only` to chain requests:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# get a token, then use it in the next request
|
|
26
|
+
TOKEN=$(postman request POST https://api.example.com/login \
|
|
27
|
+
--body '{"username":"admin","password":"pass"}' \
|
|
28
|
+
--response-only | jq -r '.token')
|
|
29
|
+
|
|
30
|
+
postman request https://api.example.com/protected \
|
|
31
|
+
--auth-bearer-token "$TOKEN"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Collection scripts
|
|
35
|
+
|
|
36
|
+
Collection files (.yaml or .json) can include scripts at the collection, folder, and request levels:
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
# in a request YAML file
|
|
40
|
+
scripts:
|
|
41
|
+
- type: afterResponse
|
|
42
|
+
code: |-
|
|
43
|
+
pm.test('Status 200', () => pm.response.to.have.status(200));
|
|
44
|
+
const res = pm.response.json();
|
|
45
|
+
pm.environment.set('_odoo_order_id', res);
|
|
46
|
+
language: text/javascript
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Script-managed variables (prefixed with `_`) are set during collection runs and chained between requests using `pm.environment.set()` and `{{variable}}` syntax.
|
|
50
|
+
|
|
51
|
+
## Available pm.* API in scripts
|
|
52
|
+
|
|
53
|
+
- `pm.response.json()` — parsed JSON response body
|
|
54
|
+
- `pm.response.to.have.status(code)` — assert status code
|
|
55
|
+
- `pm.expect(value)` — Chai BDD assertion
|
|
56
|
+
- `pm.environment.set(key, value)` — set environment variable for subsequent requests
|
|
57
|
+
- `pm.environment.get(key)` — get environment variable
|
|
58
|
+
- `pm.globals.set(key, value)` — set global variable
|
|
59
|
+
- `pm.globals.get(key)` — get global variable
|
|
60
|
+
- `console.log(...)` — log to terminal output
|
|
61
|
+
|
|
62
|
+
## Exit codes from tests
|
|
63
|
+
|
|
64
|
+
When scripts contain `pm.test()` assertions, the exit code equals the number of failed tests. This makes it suitable for CI/CD pipelines:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
postman collection run ./collection --bail --failure
|
|
68
|
+
echo "Exit code: $?"
|
|
69
|
+
```
|