Created
January 19, 2024 14:21
-
-
Save checklyalex/7eb16d73bcde329e4d17f75903cb2c00 to your computer and use it in GitHub Desktop.
A Checkly browser check example utilising a separate context and extra HTTP headers - https://playwright.dev/docs/api/class-page#page-set-extra-http-headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect, test } from '@playwright/test' | |
const headers = { | |
'X-My-Header': 'value' | |
}; | |
test('visit page and take screenshot with an extra http header for every request', async ({ browser }) => { | |
const context = await browser.newContext(); | |
await context.setExtraHTTPHeaders(headers); | |
const page = await context.newPage(); | |
const response = await page.goto(process.env.ENVIRONMENT_URL || 'https://checklyhq.com') | |
expect(response.status(), 'should respond with correct status code').toBeLessThan(400) | |
await context.close(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment