npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

postmans-to-k6

v1.5.2

Published

Convert a Postman collection to k6 JavaScript

Downloads

14

Readme

⚠ ️ 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

  • Prerequest scripts.
  • Test scripts.
  • Variables (at all scopes + dynamic).
  • Data files.
  • Authentication methods (except Hawk).
  • File uploads.
  • postman.* interface (exceptions below).
  • pm.* interface (exceptions below).
  • Global variables exposed by Postman: globals environment data iteration.
  • xml2Json conversion.
  • All Postman Schema versions.

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.

| Flag | Verbose | Default | | ---- | -------------- | ------: | | -i | --iterations | 1 |

Example:

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

Environment Variables

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

Global Variables

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

CSV Data File

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

JSON Data File

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

K6 Param Options File

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

Separate

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

Skip Pre

Skips any pre-request scripts during conversion

| Flag | Verbose | Default | | ---- | ------------ | ------- | | | --skip-pre | false |

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

Skip Post

Skips any post-request scripts during conversion

| Flag | Verbose | Default | | ---- | ------------- | ------- | | | --skip-post | false |

$ 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

  • Sending requests from scripts using pm.sendRequest.
  • Controlling request execution order using postman.setNextRequest.
  • Cookie properties, like hostOnly, session, and storeId.
  • Textual response messages:
    • responseCode.name
    • responseCode.detail
    • pm.response.reason
    • pm.response.to.have.status(reason)
    • pm.response.to.not.have.status(reason)
  • Properties returning Postman classes:
    • pm.request.url pm.request.headers
    • pm.response.headers
  • The Hawk authentication method.
  • Deprecated xmlToJson method.
  • Request IDs are changed. Postman doesn't provide them in the export so we have to generate new ones.

Other similar tools

Credits

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