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.
- Test Structure:
- Fixture.page Method
- test Function
- Element Identification and Actions:
- t.navigateTo Method
- Assertion and Evaluation:
- t.expect.eql Method
- Request Handlers:
- Test.requestHooks Method
- RequestHook Constructor
- RequestLogger Constructor