Improve the UX when a user tries to import
a wrong module name
#2818
Labels
enhancement
evaluation needed
proposal needs to be validated or tested before fully implementing it in k6
ux
#2805 solved #1741 by adding a list of the xk6 extensions and their versions bundled in the current k6 binary in the
k6 version
sub-command. While having the capability to generate and show this list is great progress, displaying it in justk6 version
is not very visible to most users.Originally, #2805 also showed the bundled extensions in the
k6 run
output as well. However, that only added more things to the already noisyk6 run
command, so we decided to hold off on that change, for now. We might choose to add it back in the future, if users request it, so please comment here with your use case if you'd like us to do that.For example, a lighter alternative would be to log the list of extensions if
--verbose
mode is used ink6 run
(and maybe alsok6 archive
,k6 inspect
andk6 cloud
🤔).Another better and less invasive approach might be to improve the error message when a user imports an unknown module. For example, if the import path starts with
k6/x
, instead of a simple error likeunknown module: k6/x/browser
, maybe we can show the list of extensions that were bundled in k6 as part of the error? Or mention that there were no extensions bundled and have a link to https://k6.io/docs/extensions/ 🤔This way, the output of
k6 run
won't be crowded by a (potentially long) list of extensions on every run, but they will be visible if--verbose
is enabled (which seems appropriate) or if there was a script error and the script tried to import a missing module name.As an addition, maybe we can also offer suggestions, if users had a typo. Similarly to how when someone types
k6 ryn
, k6 will exit with an error and print something like this:This will have UX benefits even for regular import script errors, like mistyped import paths, etc., not just for extensions.
Finally, grafana/xk6#52 probably deserves a mention here. We should probably figure out some way to warn users of old k6 versions. This can be a result of xk6 building an extension that relies on an old k6 version, or it can be just a stale install that hasn't been updated in ages. However, we have had cases where users were confused that they couldn't import
k6/execution
, for example, even though they just built their k6 binary with xk6 recently, just because xk6 used the super-old k6 version in the extension'sgo.mod
file during the build... Maybe we should even revisit grafana/xk6#44? 🤔The text was updated successfully, but these errors were encountered: