Unit testing k6 scripts

Hi @sms1070,

as was explained in your previous thread the “k6/*” imports are part of k6 they are not a JS library and k6 is not nodejs based.

This would mean that IMO running Jest tests will be really hard … You will either

  1. Need to run it only on parts that don’t use k6/* imports or figure out how provide and adequate replacement. This is probably way too much work and will have a lot of cases where your code works in Jest, but when you run it in k6 it breaks because you haven’t emulated the k6 behavior exactly.
  2. Try to run the test with k6 directly by making a script that instead of actually performance testing is running test … I don’t think Jest will bend enough for this to work though :smiley: and will definitely require a lot of JS knowledge and code.

This all bares the question why do you want to do that … I don’t think anyone else has ever tried to unit test their performance tests … I guess it could be useful in some very big tests or such with very strange logic, but still the proposed running of a single iterations seems to be sufficient in a lot of cases.