-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add other lifecycle functions to examples #36
Comments
Hi @liambutler, I am pretty sure your problem is that you try to define This has nothing to do with TS or k6 to be honest. In your case you can do: export function setup(): {token: string; users: any[]} {
return {token:"some", users: []}
} Or export let setup = (): {token: string; users: any[]} => {
return {token:"some", users: []}
} |
Thanks @mstoykov. That was something copilot suggested after multiple attempts 😅 I still believe that having more in-depth examples would make this repo even more helpful than it already is |
I am okay with merging some more examples or enhancement for the current ones. But this clearly was wrong syntax which I don't see how an example would've really helped with. The screenshot you provided is only what your editor (vscode?) provide. If you run the script it will tell you
Which just like any other syntax error there isn't really anything this project can do. Additionally, as you are using copilot it likely would just generate this code again for you, and you likely will have the same problem even if we did have examples. This literally is you export a named function in typescript. |
It would be useful to separate out the two issues here:
Had there been an example of I don't wish to annoy you with this. I just saw an opportunity for this repo to become more helpful for people who are new to K6. Of course, you are free to disregard this. |
Hi folks,
I'm having a great time using K6. Has been a big help in diagnosing some bottlenecks in my team's application. It's a beast!
Our K6 tests have traditionally been written in JS, but I'd like to convert them to TypeScript in line with the rest of our code. That's when I stumbled upon this useful repo.
However, my tests are more complex than the examples in this repo's /src folder. They use a
setup()
step, which then passes an object to the main function. I'm getting a lot of TS errorsAdmittedly I'm not the most proficient in TS, but I imagine that this would be helpful for others as well.
The text was updated successfully, but these errors were encountered: