I had k6 up and running, but now every time I try and run a test I am getting this error: ReferenceError: regeneratorRuntime is not defined.
I have tried installing and importing babel, which some people have suggested, but it did not work.
import http from "k6/http";
import { check } from "k6";
async function registerHandlers() {
const dataForBody = 'client_id=LoadTesting&grant_type=client_credentials&' +
`scope=${encodeURI('StitchApi')}&` +
`client_secret=${encodeURI(process.env.REACT_APP_CLIENT_SECRET)}`;
const messageHeaders = {
'Content-Type': 'application/x-www-form-urlencoded',
};
axios({
method: 'post',
url: process.env.REACT_APP_STITCH_AUTH_URL,
headers: messageHeaders,
data: dataForBody,
}).then((response) => {
return response;
}).catch((error) =>
global.console.log('axios error: ', error)
)
}
// const queries = JSON.parse(open("./easygraphql-load-tester-queries.json"));
const url = "https://mywebsite.net/Api/GraphQL/";
const authorization = registerHandlers();
console.log("AUTH!!!!!!", authorization);
const payload = JSON.stringify({
query: `
{
student(id: "5asdfasdfasdfasdf") {
name
}
}
` });
const params = {
headers: {
"authorization": "asdfasdfasdfasdfasdfasdfasdf",
"content-type": "application/json",
}
}
export default function () {
// console.log('query: ', queries);
let res = http.post(url, payload, params);
check(res, {
"status is 200": (r) => r.status === 200,
"is authenticated": (r) => r.json().authenticated === true,
"is correct user": (r) => r.json().user === "user",
"caption is correct": (r) => r.html("h1").text() == "Example Domain",
});
};
I just want my load testing to work!
Aucun commentaire:
Enregistrer un commentaire