Mocking request headers phantomjs and agouti

282 Views Asked by At

I'm using agouti in a project of mine to test my webpage. Everything works fine but Im having trouble finding a way to mock request headers. I'm currently using platformjs trough reuirejs and I would like to "fake" the os header sent by the browser so the system will think the requests are coming from a mobile platform. I want to do this to test that my home screen message only appears on mobile platforms.

Here is the current test.

/*
 Test that add to homescreen notification is shown first time visiting the app.
 */
func (t *AppTest) TestHomescreenNotification() {
  SetDefaultEventuallyTimeout(time.Second*7)

  RegisterTestingT(t.unit)
  page, err := agoutiDriver.NewPage()
  Expect(page.DeleteCookie("visited")).To(Succeed())
  Expect(err).NotTo(HaveOccurred())
  Expect(page.Navigate(indexPath)).To(Succeed())

  Eventually(page.Find("#message")).Should(BeFound())
  Eventually(page.Find(".growInTop")).Should(BeFound())

  /* Resetting default time out. */
  SetDefaultEventuallyTimeout(time.Second)
}
0

There are 0 best solutions below