Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@apideck/postman-to-k6
Advanced tools
Converts a Postman collection to a k6 script.
The postman-to-k6 converter utilizes your Postman collection and converts all the Postman requests, including tests, variables, ... to K6 scripts that can be executed by K6 to run performance tests.
This project is a friendly fork of the original grafana/postman-to-k6 converter, actively maintained and open for new contributions.
Feel free to contribute or pass any suggestion to improve postman-to-k6.
postman.*
interface (exceptions below).pm.*
interface (exceptions below).globals
environment
data
iteration
.xml2Json
conversion.While possible to install globally, we recommend that you, if possible, add the converter to the node_modules
of your
test project using:
$ npm install -D @apideck/postman-to-k6
or using yarn...
$ yarn add @apideck/postman-to-k6
Note that this will require you to run the converter with npx @apideck/postman-to-k6 your-postman-file
or, if you are
using an older versions of npm, ./node_modules/.bin/postman-to-k6 your-postman-file
.
$ npm install -g @apideck/postman-to-k6
To convert an exported collection to a k6 script:
$ postman-to-k6 collection.json -o k6-script.js
Then run the script in k6, as usual, using:
$ k6 run k6-script.js
Together with Nicole van der Hoeven & Paul Balogh from the K6 team, we talked about "postman-to-k6" in the K6 Office Hours podcast. We talked about how to convert a Postman collection to a k6 load test, the advantages of Postman, and the benefits of reusing automation testing scripts for performance.
Watch it on Youtube >> https://www.youtube.com/watch?v=Be66Db4wHLA
Topics covered:
Configures how many times the script will be executed before completion.
Flag | Verbose | Default |
---|---|---|
-i | --iterations | 1 |
Example:
$ postman-to-k6 collection.json --iterations 25 -o k6-script.js
Provide environment variables from a JSON file.
Flag | Verbose | Default |
---|---|---|
-e | --environment | N/A |
Example:
$ postman-to-k6 collection.json --environment environment.json -o k6-script.js
Provide global variables from a JSON file.
Flag | Verbose | Default |
---|---|---|
-g | --global | N/A |
$ postman-to-k6 collection.json --global globals.json -o k6-script.js
Provide a data file in the CSV format.
Flag | Verbose | Default |
---|---|---|
-c | --csv | N/A |
$ postman-to-k6 collection.json --csv data.csv -o k6-script.js
Pass in a data file in the JSON format.
Flag | Verbose | Default |
---|---|---|
-j | --json | N/A |
$ postman-to-k6 collection.json --json data.json -o k6-script.js
Pass K6 parameter options as a file in JSON format.
Flag | Verbose | Default |
---|---|---|
--k6-params | N/A |
$ postman-to-k6 collection.json --k6-params k6-params.json -o k6-script.js
Output the K6 summary as a file
in JSON format. This will add the K6 handleSummary(data)
to the generated script, providing the functionality that K6
will store the summary output as JSON file locally.
Flag | Verbose | Default |
---|---|---|
--k6-handle-summary-json | N/A |
$ postman-to-k6 collection.json --k6-handle-summary-json summary-report.json -o k6-script.js
Generate K6 request name tags based on available naming strategies:
request
: uses the request name as tag (example "Show all accounts")folder-request
: uses Postman folder name and the request name (example: "Accounts - Show all accounts")Flag | Verbose | Default |
---|---|---|
--k6-request-tagging | N/A |
Example for request
strategy
$ postman-to-k6 collection.json --k6-request-tagging=request -o k6-script.js
Example for folder-request
strategy
$ postman-to-k6 collection.json --k6-request-tagging=folder-request -o k6-script.js
Split requests into separate files, for easier rearrangement of the logic.
Flag | Verbose | Default |
---|---|---|
-s | --separate | false |
$ postman-to-k6 collection.json --separate -o k6-script.js
$ postman-to-k6 collection.json -s -o k6-script.js
Skips any pre-request scripts during conversion
Flag | Verbose | Default |
---|---|---|
--skip-pre | false |
$ postman-to-k6 collection.json --skip-pre -o k6-script.js
Skips any post-request scripts during conversion
Flag | Verbose | Default |
---|---|---|
--skip-post | false |
$ postman-to-k6 collection.json --skip-pre -o k6-script.js
Manage all the CLI options in a separate configuration file and pass them along to the postman-to-k6 command. To make the CLI usage easier, especially in CI/CD implementations.
All the available CLI options can be used in the config file. By passing the CLI options as parameters, you can overwrite the defined CLI options defined in the file.
Flag | Verbose | Default |
---|---|---|
--cli-options-file | false |
$ postman-to-k6 collection.json --cli-options-file cli-config.json
Example of JSON CLI config file
{
"output": "k6-script.js",
"k6-params": "config/k6-params.json",
"environment": "config/envs/team.env.json",
"separate": true
}
A collection of Postman examples are located under example
. To run one of the examples, just run it as you would any
other command:
$ postman-to-k6 example/v2/echo.json -o k6-script.js
pm.sendRequest
.postman.setNextRequest
.hostOnly
, session
, and storeId
.pm.response.reason
pm.response.to.have.status(reason)
pm.response.to.not.have.status(reason)
pm.request.auth
xmlToJson
method.A collection of blog posts and resources about postman-to-k6
Special thanks to the K6 team from Grafana for open-sourcing & growing the converter and contributing it to the community. Thanks to bookmoons for creating this tool. Also, thanks to borjacampina for creating the original incarnation of the tool.
[1.13.0] - 2024-08-18
FAQs
Convert a Postman collection to k6 JavaScript
The npm package @apideck/postman-to-k6 receives a total of 524 weekly downloads. As such, @apideck/postman-to-k6 popularity was classified as not popular.
We found that @apideck/postman-to-k6 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.