eval runs the specified javascript in the browser. The javascript must return an [][]any, where each of the []any starts with either "LOG" or "ERROR" (see testdata/testfixture.js).
(t *testing.T, js string)
| 181 | // return an [][]any, where each of the []any starts with either "LOG" or |
| 182 | // "ERROR" (see testdata/testfixture.js). |
| 183 | func eval(t *testing.T, js string) chromedp.ActionFunc { |
| 184 | return func(ctx context.Context) error { |
| 185 | var result [][]any |
| 186 | err := chromedp.Evaluate(js, &result).Do(ctx) |
| 187 | if err != nil { |
| 188 | return err |
| 189 | } |
| 190 | for _, s := range result { |
| 191 | if len(s) > 0 && s[0] == "LOG" { |
| 192 | t.Log(s[1:]...) |
| 193 | } else if len(s) > 0 && s[0] == "ERROR" { |
| 194 | t.Error(s[1:]...) |
| 195 | } else { |
| 196 | t.Error(s...) // Treat missing prefix as an error. |
| 197 | } |
| 198 | } |
| 199 | return nil |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | //go:embed testdata/testfixture.js |
| 204 | var jsTestFixture string |
no outgoing calls
no test coverage detected
searching dependent graphs…