If you want to make a version 4 UUID, you can use the uuidv4 function from the k6 JS lib repository.
If you really need other UUID versions, you must rely on an external library.
Generate v1 UUIDs
As k6 doesn't have built-in support for version 1 UUID, you'll have to use a third-party library.
This example uses a Node.js library called uuid and Browserify (to make it work in k6). For this to work, we first need to go through a few required steps:
Make sure you have the necessary prerequisites installed: Node.js and Browserify
Install the uuid library:
Run it through browserify:
Move the uuid.js file to the same folder as your script file. Now you can import it into your test script:
This example generates a v1 UUID: