Unexpected token, expected ; (2:7)

I converted my first .har file and have found an error on the second line ( a line I did not make & don’t know how to fix)

ERRO[0000] SyntaxError: file:///C:/0WORK/activity.har: Unexpected token, expected ; (2:7)
   1 | {
> 2 |   "log": {
      |          ^
   3 |     "version": "1.2",
   4 |     "creator": {
   5 |       "name": "Firefox", at <eval>:2:28542(114) 

Here is the top of my .js

import { group, sleep } from 'k6';
import http from 'k6/http';

// Version: 1.2
// Creator: Firefox
// Browser: Firefox

Any ideas?

Hi @gary,

Looking at the error it seems that you are running k6 run script.har but you should be running it with the JS script it produced not with the har file …

Classified as Public

Hi @mstoykov,

My bad, there was a typo, here is the command again and the result. I made a few conversion .js files from the .har file to keep an original and make versions with my edits.

C:\0WORK>k6 run testscript.js

/\ |‾‾| /‾‾/ /‾/

/\ / \ | |_/ / / /

/ \/ \ | | / ‾‾\

/ \ | |‾\ \ | (_) |

/ __________ \ |__| \__\ \___/ .io

ERRO[0000] SyntaxError: file:///C:/0WORK/testscript.js: Unexpected token, expected ; (2:7)

1 | {

> 2 | "log": {

> ^

3 | "version": "1.2",

4 | "creator": {

5 | "name": "Firefox", at <eval>:2:28542(114)

Here is my .har file with the offending token.

image001.png

@gary, judging by the error you’re getting, testscript.js doesn’t seem to contain valid JavaScript code… Instead, it’s contents seem exactly like the contents of your .har file :wink: So, it looks to me like you somehow overwrote the contents of your converted script (which k6 can execute) with the contents of the .har file (which it can’t directly execute). Please open the file in an editor and verify that you’re trying to run a valid JS script.

Classified as Public

Hi Ned,

I ran the convert step again as instructed and bingo, alles goed!

Many thanks G*

:+1: