Home

Awesome

⚠ ️ This project is no longer maintained in this repository.

Development and maintenance have been stopped in this repository.

A fork of this project is active and maintained at apideck-libraries/postman-to-k6.

Postman-to-k6

Converts a Postman collection to a k6 script.

Content

Features

Installation

Local Installation (recommended)

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 postman-to-k6

# or using yarn...

$ yarn add postman-to-k6

Note that this will require you to run the converter with npx 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.

Global Installation

$ npm install -g postman-to-k6

Docker

The tool is also available for usage in Docker. To download an image with the tool from DockerHub:

$ docker pull loadimpact/postman-to-k6

Usage

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

Options

Iterations

Configures how many times the script will be executed before completion.

FlagVerboseDefault
-i--iterations1

Example:

$ postman-to-k6 collection.json --iterations 25 -o k6-script.js

Environment Variables

Provide environment variables from a JSON file.

FlagVerboseDefault
-e--environmentN/A

Example:

$ postman-to-k6 collection.json --environment environment.json -o k6-script.js

Global Variables

Provide global variables from a JSON file.

FlagVerboseDefault
-g--globalN/A
$ postman-to-k6 collection.json --global globals.json -o k6-script.js

CSV Data File

Provide a data file in the CSV format.

FlagVerboseDefault
-c--csvN/A
$ postman-to-k6 collection.json --csv data.csv -o k6-script.js

JSON Data File

Pass in a data file in the JSON format.

FlagVerboseDefault
-j--jsonN/A
$ postman-to-k6 collection.json --json data.json -o k6-script.js

K6 Param Options File

Pass K6 parameter options as a file in JSON format.

FlagVerboseDefault
--k6-paramsN/A
$ postman-to-k6 collection.json --k6-params k6-params.json -o k6-script.js

Separate

Split requests into separate files, for easier rearrangement of the logic.

FlagVerboseDefault
-s--separatefalse
$ postman-to-k6 collection.json --separate -o k6-script.js
postman-to-k6 collection.json -s -o k6-script.js

Skip Pre

Skips any pre-request scripts during conversion

FlagVerboseDefault
--skip-prefalse
$ postman-to-k6 collection.json --skip-pre -o k6-script.js

Skip Post

Skips any post-request scripts during conversion

FlagVerboseDefault
--skip-postfalse
$ postman-to-k6 collection.json --skip-pre -o k6-script.js

Docker Usage

Using the Docker image, you execute the tool as follows:

$ docker run -it \
    -v "/path/to/postman/collection/:/postman/" \
    loadimpact/postman-to-k6 \
    /postman/my-collection.json \
    -o /postman/test.js

and then execute the k6 test using:

$ k6 run /path/to/postman/collection/test.js

Examples

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

Unsupported Features

Other similar tools

Credits

Thanks to bookmoons for creating this tool. Also, thanks to borjacampina for creating the original incarnation of the tool.