A JavaScript package (node_module) exposing a function that takes a LI-HAR config as parameter and returns a K6 script.
The JS package should be a standalone package (node_module) and be runnable in a web browser environment (last 2 release Chrome, Firefox, Safari, Edge) as well as in Node.js (current LTS release).
// har-to-k6 lib
export function liHARToK6Script(liHARConfig) {
return convertToK6Script(liHARConfig);
}
// Usage
import { liHARToK6Script } from "har-to-k6";
const config = {
log: {
entries: [
{
request: {
method: "POST",
url: "http://test.loadimpact.com/login",
headers: [
{
"name": "Content-Type",
"value": "application/json"
}
],
postData: {
"mimeType": "application/json",
"text": "{\"user\":\"admin\",\"password\":\"123\"}"
},
},
}
],
}
};
liHARToK6Script(config);
// Output
`import http from "k6/http";
export default function() {
var payload = JSON.stringify({ email: "aaa", password: "bbb" });
http.post("http://test.loadimpact.com/login", payload, {
headers: { "Content-Type": "application/json" }
});
}`
Resources