Skip to content
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

xk6-browser should be importable as a k6 module #667

Merged
merged 3 commits into from
Dec 7, 2022

Conversation

inancgumus
Copy link
Member

Closes #662

Moves the module registration logic to a new pkg called browser.
This change made to be consistent. As it used like so in other modules.
@inancgumus inancgumus marked this pull request as ready for review December 6, 2022 07:55
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for making it consistent with the other experimental modules 👍

I think we should get approval from the k6 team too.

Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I have left some comments that are likely mostly for openning new issues or taking notes.


// TestModuleNew tests registering the module.
// It doesn't test the module's remaining functionality as it is
// already tested in the tests/ integration tests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall the tests then just import browser and test it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferably not in this PR but later ;)

Copy link
Member Author

@inancgumus inancgumus Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks :) However, I liked keeping this simple test next to the module registration. So that it would be easier to make changes to both code and tests when needed (instead of jumping to the other parts of the code base (tests/).

)

func init() {
if _, ok := os.LookupEnv("K6_BROWSER_PPROF"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should remember that this won't work with core k6.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine tbh.

Out of curiosity, why wouldn't the init function run when k6 imports the module? I thought that all init functions had to to run (which is an unwanted side affect sometimes).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you import a package.
And we are not going to import this package as that will also register the extension as k6/x/browser - the init below this one.

Which is like the whole point of this PR ;)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, yep, of course 🙂

Copy link
Member Author

@inancgumus inancgumus Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this code in our own instances for testing, so that won't be a problem. Thanks for letting us know, though 👍

@inancgumus inancgumus merged commit 65d53fe into main Dec 7, 2022
@inancgumus inancgumus deleted the add/662-importable-browser branch December 7, 2022 11:41
@inancgumus inancgumus added the dependencies Pull requests that update a dependency file label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xk6-browser should be importable as a k6 module
3 participants