-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ Add global setup for cookie acceptance in E2E tests
- Loading branch information
Showing
5 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type FullConfig, chromium } from '@playwright/test' | ||
|
||
async function globalSetup(config: FullConfig) { | ||
const { baseURL, storageState } = config.projects[0].use | ||
const browser = await chromium.launch() | ||
const page = await browser.newPage() | ||
await page.goto(`${baseURL}/`) | ||
|
||
const cookieButton = page.getByRole('button', { | ||
name: 'Accept All Cookies', | ||
}) | ||
await cookieButton.click({ timeout: 3000, force: true }).catch(() => {}) | ||
await page.context().storageState({ path: storageState as string }) | ||
|
||
await browser.close() | ||
} | ||
|
||
export default globalSetup |
This file contains 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
This file contains 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
This file contains 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