diff --git a/tests/element_handle_test.go b/tests/element_handle_test.go index ef50fe32a..199e182b3 100644 --- a/tests/element_handle_test.go +++ b/tests/element_handle_test.go @@ -299,8 +299,7 @@ func TestElementHandleIsChecked(t *testing.T) { } func TestElementHandleQueryAll(t *testing.T) { - // tests are faster than parallel execution. - // do not make this test parallel. + t.Parallel() const ( wantLiLen = 2 @@ -316,6 +315,8 @@ func TestElementHandleQueryAll(t *testing.T) { `, nil) t.Run("element_handle", func(t *testing.T) { + t.Parallel() + el, err := p.Query("#aul") require.NoError(t, err) @@ -325,12 +326,16 @@ func TestElementHandleQueryAll(t *testing.T) { assert.Equal(t, wantLiLen, len(els)) }) t.Run("page", func(t *testing.T) { + t.Parallel() + els, err := p.QueryAll(query) require.NoError(t, err) assert.Equal(t, wantLiLen, len(els)) }) t.Run("frame", func(t *testing.T) { + t.Parallel() + els, err := p.MainFrame().QueryAll(query) require.NoError(t, err) assert.Equal(t, wantLiLen, len(els)) diff --git a/tests/page_test.go b/tests/page_test.go index 741889df8..4cf95a255 100644 --- a/tests/page_test.go +++ b/tests/page_test.go @@ -350,17 +350,11 @@ func TestPageInputSpecialCharacters(t *testing.T) { } func TestPageFill(t *testing.T) { - // these tests are not parallel by intention because - // they're testing the same page instance and they're - // faster when run sequentially. + t.Parallel() - p := newTestBrowser(t).NewPage(nil) - p.SetContent(` - - - - - `, nil) + // Subtests race with each other since they change the same page content. + // We could make each subtest to create and run their own browsers + // (and not share them), but that would make the test run 2X. happy := []struct{ name, selector, value string }{ {name: "text", selector: "#text", value: "fill me up"}, @@ -373,13 +367,34 @@ func TestPageFill(t *testing.T) { {name: "unfillable", selector: "#unfillable", value: "can't touch this"}, } for _, tt := range happy { + tt := tt t.Run("happy/"+tt.name, func(t *testing.T) { + t.Parallel() + + p := newTestBrowser(t).NewPage(nil) + p.SetContent(` + + + + + `, nil) + p.Fill(tt.selector, tt.value, nil) require.Equal(t, tt.value, p.InputValue(tt.selector, nil)) }) } for _, tt := range sad { + tt := tt t.Run("sad/"+tt.name, func(t *testing.T) { + t.Parallel() + + p := newTestBrowser(t).NewPage(nil) + p.SetContent(` + + + + + `, nil) require.Panics(t, func() { p.Fill(tt.selector, tt.value, nil) }) }) }