-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathindex.js
33 lines (27 loc) · 1.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { RequestLogger, RequestHook } from 'testcafe';
fixture `Set a Custom Referer`
.page`http://example.com/`;
export class MyRequestHook extends RequestHook {
constructor (requestFilterRules, responseEventConfigureOpts) {
super(requestFilterRules, responseEventConfigureOpts);
}
async onRequest (event) {
event.requestOptions.headers['referer'] =
'http://my-modified-referer.com';
}
async onResponse () {
}
}
const hook = new MyRequestHook();
const logger = RequestLogger(
['https://devexpress.github.io/testcafe/example/', 'http://example.com/'],
{
logRequestHeaders: true,
}
);
test
.requestHooks([hook, logger])('Check the Referer Value', async t => {
await t.navigateTo('https://devexpress.github.io/testcafe/example/');
await t.expect(logger.contains(r => r.request.url === 'https://devexpress.github.io/testcafe/example/')).ok();
await t.expect(logger.requests[0].request.headers['referer']).eql('http://my-modified-referer.com');
});