It looks like you’re trying to access page.response which will be undefined since the page object doesn’t define a response member variable. If you print the response which is returned from page.goto you should see that it prints {}.
check’s first input variable is the value you want to check against. response.ok will return null since that is not defined, although ok() is defined. What I think you want is to pass in response, and in the check’s test body you want to call status() to retrieve the http status code:
If I use a http.get(‘mypage’) to load my page, the response back from this is half a webpage because the sire requires Javascript and a browser to load the body.
If I use page.goto(‘mypage’), then I cannot use the response object as it is not defined.
How do I get past my login page and onbto the page under test (in this case a dashboard) using K6?
I’m a little confused as to what you are trying to do with the response, can you elaborate a bit more why you need the response when you navigate to the website under test using page.goto?
Which part of the response object is undefined when working with page.goto?
Thanks for the example code which outlines your exact requirements and problem you are facing. page.waitForNavigation returns the response for the page.click action, and when working with Promise.All when all promises are fulfilled an array with the fulfilled values is returned.
What this means is that the response const variable in your example needs to be iterated over to retrieve the object which contains the response and work with that object.