k6
k6 copied to clipboard
Using a generator as default function
Now that k6 supports generator the following code
export default function* () {
console.log(1);
yield 1;
console.log(2);
yield 2;
console.log(3);
yield 3;
}
is valid and will not do anything when run with 10 iterations as executing the generator function returns a Generator.
Arguably this should just give a ~warning~error.
Same for setup
, teardown
and handleSummary
Arguably this should just give a warning.
Hmm I think it should be a validation error, not just a warning. Is there a reason to support generators for any function that is specified in a scenario.exec
?
Ah yeah, I mis~spoke~typed - it should be an error
Is there a reason to support generators for any function that is specified in a scenario.exec?
You can argue that the above should run until hte first yield on the first iteration, until the second on the second one and so on.
I don't particularly thing this is useful though, and likely will be a bit invovled to implement. Even more so to actually document and find a reasonable use case
Good points, something like that might be useful :thinking: However, if we start with throwing an error now, we can always relax that constraint in the future, if we decide to support use cases like that.
After an internal discussion, we decided to clean a milestone since the issue was jumping between milestones without completion.
Once we determine which milestone it lands, we set the right one.