Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Add tests for BrowserContextOptions #65

Merged
merged 5 commits into from
Nov 5, 2021

Conversation

robingustafsson
Copy link
Member

No description provided.

Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

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

Great, just minor things.

common/types.go Outdated Show resolved Hide resolved
common/types.go Outdated
return ColorSchemeToString[c]
}

var ColorSchemeToString = map[ColorScheme]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be unexported since it's only used in this package. Otherwise you'd have to add a comment to document it, or the linter should complain. Right now it doesn't appear to be setup properly (I'll add a note to #58 mentioning this as well).

But in general instead of maintaining our own conversion maps for these things, in k6 we use enumer which handles this for us, including the JSON marshalling. I can create an issue and do that in a follow-up PR if you don't have time right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yeah the enumer lib seems exactly like what we need 😅 Yes please, I'd prefer if you could help with the move to enumer in a separate PR 🙏

defer bt.Browser.Close()

t.Run("BrowserContextOptions", func(t *testing.T) {
t.Run("should have correct default values", func(t *testing.T) { testBrowserContextOptionsDefaultValues(t, bt) })
Copy link
Contributor

Choose a reason for hiding this comment

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

I've noticed you use this pattern of using a separate testing function. Why not just have it inline here? I think that would be more readable instead of having to go to the function, which in a large file is a chore (if you don't have go-to-definition setup).

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess just a preference to have sort of TOC of the tests in a file (and yes I rely on go-to-definition), not a strongly held preference by any means and you and Inanc should enforce whatever style you prefer :)

Perfhaps we can change all the tests in a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

Yep, I created an issue for doing that: #52

We can restructure the extension after ObsCon 🤞

tests/browser_context_options_test.go Outdated Show resolved Hide resolved
@imiric imiric mentioned this pull request Nov 5, 2021
60 tasks
@robingustafsson robingustafsson force-pushed the tests/add-browser-context-options-tests branch from 7e4c239 to fefec9a Compare November 5, 2021 15:24
@robingustafsson
Copy link
Member Author

Seems like gh is having some issues, seeing 502 gateway errors pulling some deps in tests 🤷‍♂️ Tests are passing on Linux and locally on my Mac though so I'll merge to main anyways :)

@robingustafsson robingustafsson merged commit 3c85162 into main Nov 5, 2021
@robingustafsson robingustafsson deleted the tests/add-browser-context-options-tests branch November 5, 2021 15:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants