Getting Error while generating UUID in K6

I want to generate the random GUID in k6.

Followed the below link to generate the random UUID.

Getting the below error:

Requesting you to help with the same.

Hello!

It looks like browserify generates the file in “UTF-16 Little Endian” encoding. Switching the encoding to “UTF-8 with BOM” solves the problem.

The easier solution is probably just to use the UUID library from jslib as documented here:

import { uuidv4 } from "https://jslib.k6.io/k6-utils/1.0.0/index.js";
export default function() {
  let randomUUID = uuidv4();
  console.log(randomUUID); // 35acae14-f7cb-468a-9866-1fc45713149a
}
1 Like