Skip to content

Latest commit

 

History

History

set-a-custom-referrer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Set a Custom Referrer

Test Code: index.js

Tested Page: TestCafe Example Page

The HTTP referrer (also known as referer) is a request header that indicates from where the user navigated.

This example shows how to set a custom referrer for the specified requests during tests.

Before the test begins, a request hook and a request logger are created. When the browser sends a request, the hook overwrites its 'Referer' header with the specified value.

The test starts on a dummy page and navigates to another page with the t.navigateTo method. The request logger records the requests sent during the test. The t.expect.eql method checks the header value to verify that the referrer was overwritten.

TestCafe API Used in This Example