K6 implementation in webdriverio

I am relatively new to webdriverio framework and now trying out to implement K6 load test into my webdriverio framework for UI and API performance testing. We use yarn dependency manager. Referring to the configuration instructions provided in https://k6.io/docs/using-k6/modules#bundling-node-modules , would like to know if it is really necessary to use the bundling packages, or I can directly use the k6. Will this run into any future issues? Also, is it worth to implement k6 instead of jmeter? And, is it possible to run k6 by adding script in package.json? Anyone who have any hints, please help out!

Hi @Fabien,

I’m not familiar with WebdriverIO, but at first glance a deep integration with k6 doesn’t seem possible. This is because k6 doesn’t run on NodeJS, but uses a JavaScript runtime written in Go, so you won’t be able to import any of its libraries outside of k6 scripts themselves.

That said, if WebdriverIO supports running external executables you might be able to trigger a k6 run command with the summary export option or JSON/CSV outputs, and then parse the results in your WebdriverIO tests.

That bundling modules documentation is about including additional JS dependencies in your k6 scripts to be run with the k6 runtime, but running the bundle with anything but k6 won’t be possible, since again, k6 doesn’t use NodeJS.

Also, is it worth to implement k6 instead of jmeter?

Of course, k6 is better, but you might get a biased response on this forum. :slight_smile:

And, is it possible to run k6 by adding script in package.json?

Sure, since you can run external executables via npm’s package.json, you could have a scripts entry like:

  "scripts": {
    "k6": "k6 run script.js"

… which you could then run with npm run k6.



Thank you Ivan. Would also like to know if it is possible to integrate k6 onto a cucumber /mocha test framework in node ?

Not sure about Cucumber/Mocha, but you should be able to use Jest by mocking the k6 APIs. See this post and thread for details.

There’s no official support or documentation about this (yet), but if you make some progress please post your findings on the forum so that others may benefit. :slight_smile:


@Fabien - I was trying to do the same use cucumber / mocha test for k6. Unfortunately, this is not doable. Because k6 has it’s own test runner and is a self contained application written in go. It is not a node module.