From 6f5222b7950204bfdb3929f9bf5b3328941b7954 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Mon, 21 Aug 2023 15:00:50 +0100 Subject: [PATCH] Add a integration test for k6 object injection This test will evaluate and return the value. It should be an empty object and not null. --- tests/browser_context_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/browser_context_test.go b/tests/browser_context_test.go index e3f4a32f0..1be6d46c5 100644 --- a/tests/browser_context_test.go +++ b/tests/browser_context_test.go @@ -432,3 +432,18 @@ func TestBrowserContextCookies(t *testing.T) { }) } } + +func TestK6Object(t *testing.T) { + b := newTestBrowser(t, withFileServer()) + p := b.NewPage(nil) + + url := b.staticURL("empty.html") + r, err := p.Goto(url, nil) + require.NoError(t, err) + require.NotNil(t, r) + + k6Obj := p.Evaluate(b.toGojaValue(`() => window.k6`)) + k6ObjGoja := b.toGojaValue(k6Obj) + + assert.False(t, k6ObjGoja.Equals(goja.Null())) +}