Skip to content
JSON config representation of K6 script
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
bin
example
src
test
.editorconfig
.gitattributes
.gitignore
.npmignore
ARCHITECTURE.md
CHANGELOG.md
LICENSE
README.md
STYLE.md
ava.config.js
cli-tool.spec.md
converter.spec.md
li-har.spec.md
package.json
standalone.js
webpack.config.js
yarn.lock

README.md

har-to-k6

Convert LI-HAR and HAR to K6 script.

CLI Usage

Install Globally - preferably using nvm (at least on Unix/Linux systems to avoid filesystem permission issues when using sudo):

npm install --global har-to-k6

Locally - into node_modules
Note: that this will require you to run the converter with node node_modules/.bin/har-to-k6 ...

npm install har-to-k6

Npx

npx har-to-k6 archive.har -o loadtest.js

Convert

Use har-to-k6 to convert.

har-to-k6 archive.har -o loadtest.js

API Usage

Install

npm install --save har-to-k6

Use liHARToK6Script() to convert.

const fs = require("fs");
const { liHARToK6Script } = require("har-to-k6");

async function run () {
  const archive = readArchive();
  const { main } = await liHARToK6Script(archive);
  fs.writeFileSync("./load-test.js", main);
}

Use validate() to run validation alone. Returns without error for a valid archive. Throws InvalidArchiveError for validation failure.

const { InvalidArchiveError, validate } = require("har-to-k6");

const archive = readArchive();
try {
  validate(archive);
} catch (error) {
  if (error instanceof InvalidArchiveError) {
    // Handle invalid archive
  } else {
    throw error;
  }
}

Browser Usage

har-to-k6 can be ran in the browser. This exposes the standard API under harToK6.

Importing as ES module

import { liHARToK6Script } from "har-to-k6";

CJS style

const { liHARToK6Script } = require("har-to-k6");

Script tag

Load standalone.js into your HTML page:

<html>
  <head>
    <title>HAR Converter</title>
    <script src="standalone.js"></script>
    <script src="index.js"></script>
  </head>
</html>

The API is available:

async function run () {
    const archive = readArchive();
    harToK6.validate(archive);
    const { main } = await harToK6.liHARToK6Script(archive);
    displayResult(main);
}

Specification

This is a specification describing the following:

Credits

Thanks to bookmoons for creating this tool 🎉

You can’t perform that action at this time.