Coder Social home page Coder Social logo

har-to-k6's Introduction

har-to-k6 cover image

har-to-k6

Converts LI-HAR and HAR to K6 script.

GitHub Actions Status NPM Version NPM Weekly Downloads DockerHub



Content

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 --save har-to-k6

Note that this will require you to run the converter with npx har-to-k6 your-har-file or, if you are using an older version of npm, ``./node_modules/.bin/har-to-k6 your-har-file`.

Global Installation

$ npm install --global har-to-k6

Docker

$ docker pull loadimpact/har-to-k6:latest

Usage

CLI Usage

Npx

$ npx har-to-k6 archive.har -o my-k6-script.js

From node_modules

$ ./node_modules/.bin/har-to-k6 archive.har -o my-k6-script.js

Global

$ har-to-k6 archive.tar -o my-k6-script.js

Programmatic Usage

Converting

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);
}

Validating

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";

CommonJS style

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

Using a <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>

Example

The API is available:

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

Specifications

Credits

Thanks to bookmoons for creating this tool ๐ŸŽ‰

har-to-k6's People

Contributors

bookmoons avatar legander avatar allansson avatar w1kman avatar edvinasdaugirdas avatar simskij avatar dependabot[bot] avatar sniku avatar robingustafsson avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.