Error generating junit report in CI but works well in local

I have this running on the command line on my local machine and generates the junit.xml file:
k6 run -e ENVIRONMENT=test test/api.ts | k6-to-junit junit.xml

When same command is run on the CI server, it gives me this error:
ERRO[0000] accepts 1 arg(s), received 4: arg should either be "-", if reading script from stdin, or a path to a script file

Note:
k6-to-junit is an npm package that I have installed as part of my project. Running npm install on the command line should include that package as it is part of my devDependencies on package.json

Hi @poponuts,
welcome to the community forum :tada:

is test/api.ts a local file? If yes, then you should use the correct relative path like this ./test/api.ts.

The error is generated from the k6 run command. Apparently, in your CI you have a misconfiguration that generates a syntax error for the run command.

Thanks @codebien , yes, the test is local and it runs only when | k6-to-junit junit.xml is not included with or without the ./

With the following command line:
k6 run -e ENVIRONMENT=test ./test/api.ts | k6-to-junit junit.xml

Same result based on the above:
ERRO[0000] accepts 1 arg(s), received 4: arg should either be “-”, if reading script from stdin, or a path to a script file
make: *** [k6_run_tests] Error 255

Hi @poponuts,
did you try to run before with the minimum viable command? Something like:

k6 run -e ENVIRONMENT=test ./test/api.ts

If you are not getting an error then the issue could be related to how you’re using the pipe for your CI instructions.

Yes, @codebien it works without the pipe on the CI.
One critical info I forgot to mention is that this command is run via a docker-compose.yaml file with the following snippet:

 k6-tests:
    image: loadimpact/k6
    entrypoint: k6 run -e ENVIRONMENT=test ./test/api.ts | k6-to-junit junit.xml

Would you know how to handle pipe | on this?

Hi @poponuts,
how the pipe behaves depends on the shell you’re using in your CI. I suggest to you to ask for support directly in the channels of the vendor of your CI.
Here we focus mostly on support on issues regarding k6.