I’d like to be able to share some scripting between setup() and execution.
I’m trying to set up a repo where we have a set of stories that consume a bunch of library functions that behave reasonably either in setup() code or during the default execution (when the VUs are running the actual load test). On the face of it this seems easy, but error handling doesn’t make a lot of sense without completely abstracting what’s built in to k6 as during execution you want to just check to mark the failure and move on but during setup() if something fails, we’re losing critical structure we need for the test to make sense so we want a proper failure.
The other problem I’ve run in to is is that
throw new Error(...) in setup() code doesn’t give a useful stack trace.
Has anyone else tried to share code in multiple modes and solved this already?