Hi ,
I am trying to run K6 on my machine and unable to run it as it is giving me error:
ERRO[0000] could not initialize ‘code.js’: could not load JS test ‘file:///C:/Users/ppraval6/Desktop/K6/bh_mps_k6/code.js’: file:///C:/Users/ppraval6/Desktop/K6/bh_mps_k6/code.js: Line 28:25 Unexpected token function (and 6 more errors)
I am using windows 10 OS and k6 v0.39.0 (2022-07-05T10:50:14+0000/v0.39.0-0-g5904fd8, go1.18.3, windows/amd64)
The code used to test is import { browser } from ‘k6/experimental/browser’;
import { check } from ‘k6’;
export const options = {
scenarios: {
ui: {
executor: ‘shared-iterations’,
options: {
browser: {
type: ‘chromium’,
},
},
},
},
thresholds: {
checks: [“rate==1.0”]
}
}
export default async function () {
const context = browser.newContext();
const page = context.newPage();
try {
await page.goto(‘someurl’);
page.locator('input[name="login"]').type('admin');
page.locator('input[name="password"]').type('123');
const submitButton = page.locator('input[type="submit"]');
await Promise.all([page.waitForNavigation(), submitButton.click()]);
check(page, {
'header': p => p.locator('h2').textContent() == 'Welcome, admin!',
});
} finally {
page.close();
}
}
Hi @pattelachinky,
Please make sure you’re using these quotes: " and '. Instead of ‘, “, ”.
Thanks.