$npx -y skills add LambdaTest/agent-skills --skill newman-script-helperGenerate Newman CLI run commands with the correct flags, options, and configurations. Use this skill whenever the user wants to run a Postman collection via Newman, needs help with Newman command syntax, wants to configure reporters (HTML, JUnit, CLI, JSON), set environments or g
| 1 | # Newman Script Generator |
| 2 | |
| 3 | Generate complete, ready-to-run Newman CLI commands tailored to the user's collection, environment, and reporting needs. |
| 4 | |
| 5 | ## What Newman Is |
| 6 | |
| 7 | Newman is Postman's official CLI collection runner. It lets you run Postman collections from the terminal, CI pipelines, and scripts. |
| 8 | |
| 9 | Install: `npm install -g newman` |
| 10 | Optional HTML reporter: `npm install -g newman-reporter-htmlextra` |
| 11 | |
| 12 | --- |
| 13 | |
| 14 | ## Core Command Structure |
| 15 | |
| 16 | ``` |
| 17 | newman run <collection> [options] |
| 18 | ``` |
| 19 | |
| 20 | `<collection>` can be: |
| 21 | - A local file path: `./my-collection.json` |
| 22 | - A Postman API URL: `https://api.getpostman.com/collections/<id>?apikey=<key>` |
| 23 | - A public share link |
| 24 | |
| 25 | --- |
| 26 | |
| 27 | ## Key Flags Reference |
| 28 | |
| 29 | ### Input / Source |
| 30 | | Flag | Description | |
| 31 | |------|-------------| |
| 32 | | `-e, --environment <path>` | Postman environment file (.json) | |
| 33 | | `-g, --globals <path>` | Postman globals file (.json) | |
| 34 | | `-d, --iteration-data <path>` | CSV or JSON data file for iterations | |
| 35 | | `--folder <name>` | Run only a specific folder by name | |
| 36 | |
| 37 | ### Execution Control |
| 38 | | Flag | Description | |
| 39 | |------|-------------| |
| 40 | | `-n, --iteration-count <n>` | Number of iterations to run | |
| 41 | | `--timeout <ms>` | Overall run timeout in milliseconds | |
| 42 | | `--timeout-request <ms>` | Per-request timeout in milliseconds | |
| 43 | | `--timeout-script <ms>` | Per-script timeout in milliseconds | |
| 44 | | `--delay-request <ms>` | Delay between requests (ms) | |
| 45 | | `--bail` | Stop run on first test failure | |
| 46 | | `--ignore-redirects` | Don't follow HTTP redirects | |
| 47 | | `-k, --insecure` | Disable SSL certificate verification | |
| 48 | |
| 49 | ### Reporters |
| 50 | | Flag | Description | |
| 51 | |------|-------------| |
| 52 | | `-r cli` | Default terminal output | |
| 53 | | `-r json` | JSON results file | |
| 54 | | `-r junit` | JUnit XML (for CI systems) | |
| 55 | | `-r htmlextra` | Rich HTML report (requires separate install) | |
| 56 | | `--reporter-json-export <path>` | Output path for JSON report | |
| 57 | | `--reporter-junit-export <path>` | Output path for JUnit XML | |
| 58 | | `--reporter-htmlextra-export <path>` | Output path for HTML report | |
| 59 | | `--reporter-htmlextra-title <title>` | Title for HTML report | |
| 60 | |
| 61 | ### Environment Variables (inline override) |
| 62 | ``` |
| 63 | --env-var "KEY=value" |
| 64 | --global-var "KEY=value" |
| 65 | ``` |
| 66 | |
| 67 | --- |
| 68 | |
| 69 | ## Common Patterns |
| 70 | |
| 71 | ### Basic run with environment |
| 72 | ```bash |
| 73 | newman run collection.json -e environment.json |
| 74 | ``` |
| 75 | |
| 76 | ### Run with HTML + JUnit reports (CI-friendly) |
| 77 | ```bash |
| 78 | newman run collection.json \ |
| 79 | -e environment.json \ |
| 80 | -r cli,junit,htmlextra \ |
| 81 | --reporter-junit-export results/junit.xml \ |
| 82 | --reporter-htmlextra-export results/report.html \ |
| 83 | --reporter-htmlextra-title "API Test Results" |
| 84 | ``` |
| 85 | |
| 86 | ### Data-driven run (CSV iterations) |
| 87 | ```bash |
| 88 | newman run collection.json \ |
| 89 | -e environment.json \ |
| 90 | -d test-data.csv \ |
| 91 | -n 5 |
| 92 | ``` |
| 93 | |
| 94 | ### Run a single folder only |
| 95 | ```bash |
| 96 | newman run collection.json \ |
| 97 | -e environment.json \ |
| 98 | --folder "Auth Tests" |
| 99 | ``` |
| 100 | |
| 101 | ### Fail fast + timeout |
| 102 | ```bash |
| 103 | newman run collection.json \ |
| 104 | -e environment.json \ |
| 105 | --bail \ |
| 106 | --timeout-request 5000 |
| 107 | ``` |
| 108 | |
| 109 | ### Run from Postman API (no local file) |
| 110 | ```bash |
| 111 | newman run "https://api.getpostman.com/collections/COLLECTION_ID?apikey=$POSTMAN_API_KEY" \ |
| 112 | -e environment.json |
| 113 | ``` |
| 114 | |
| 115 | --- |
| 116 | |
| 117 | ## How to Generate Commands |
| 118 | |
| 119 | When the user asks for a Newman command: |
| 120 | |
| 121 | 1. **Identify collection source** — local file, Postman API, or share link |
| 122 | 2. **Ask about environment** — do they have a `.json` env file? Which env (dev/staging/prod)? |
| 123 | 3. **Determine reporting needs** — terminal only, HTML, JUnit for CI? |
| 124 | 4. **Check for iteration data** — CSV/JSON test data file? |
| 125 | 5. **Note any special needs** — specific folder, SSL issues, timeouts, bail on failure |
| 126 | 6. **Assemble the command** with proper flag order and line-continuation for readability |
| 127 | 7. **Include install commands** if reporters like `htmlextra` are needed |
| 128 | |
| 129 | Always output: |
| 130 | - The full Newman command (use `\` for multi-line readability in bash) |
| 131 | - Any prerequisite install steps |
| 132 | - A brief explanation of each flag used |
| 133 | - An example of what the output/report will look like |
| 134 | |
| 135 | --- |
| 136 | |
| 137 | ## Output Format Example |
| 138 | |
| 139 | ```bash |
| 140 | # Install dependencies (if not already installed) |
| 141 | npm install -g newman |
| 142 | npm install -g newman-reporter-htmlextra |
| 143 | |
| 144 | # Run the collection |
| 145 | newman run ./collections/my-api.json \ |
| 146 | -e ./e |