I would be interested to create a shared project in my company github’s repo with a file structure that has shared files in a common folder and specific folders per team. This would allow every team to drop their scenarios (or .js file) to add to a mixed traffic test. I am working on it now. I would like to have a JS Object that build the “options” parameter so that every dropped .js file could be added with a given configuration. However I am not sure how I can set the “exec” parameter if the test function isn’t in the same file. When I try then I get a goja error since function can be a JSON element.
Is it possible to do that and if so, any pointer for me please?
I am not sure what you mean by “function can be a JSON element”, but you can re-export the function used in the imported file and adjust the
exec option to the new name. This will be easier once we have Test suites / execute multiple scripts with k6 · Issue #1342 · grafana/k6 · GitHub implemented, but you should still be able to achieve most of what you want with k6 today.
We don’t have documentation for this use case yet, but I’ve collected some previous instances of similar questions and our solutions in this docs issue: Add examples for scenario reuse · Issue #255 · grafana/k6-docs · GitHub
Take a look and if you have any more questions, please submit a simplified example with 1 or 2 dummy files that doesn’t do what you expect it to do, so we can give concrete suggestions for fixes.
I should maybe not tell a solution. If I was writing Acceptance Criteria, I would say:
- My company has a project with shared files and libraries (ie. login/logout, etc)
- I or any other team can drop a test in my or their specific folder and the test will run when tests start
- Drooping a test in a folder would not require to update shared files in order to run it
Is that possible by some way right now?