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 type { PlaywrightTestConfig } from '@playwright/test'; | |
import { devices } from '@playwright/test'; | |
import { AzureReporterOptions } from '@alex_neo/playwright-azure-reporter/dist/playwright-azure-reporter'; | |
/** | |
* See https://playwright.dev/docs/test-configuration. | |
*/ | |
const config: PlaywrightTestConfig = { | |
testDir: './tests', | |
/* Maximum time one test can run for. */ |
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
// Throw Error: Path is not available when connecting remotely. Use saveAs() to save a local copy. | |
import { test, expect } from '@playwright/test'; | |
import fs from 'fs'; | |
test('download result', async ({ page }) => { | |
await page.goto('https://demo.playwright.dev/svgomg'); | |
await page.locator('.menu-item >> text=Demo').click(); | |
const downloadButton = page.locator('a[title=Download]'); | |
await expect(downloadButton).toHaveAttribute('href', /blob/); | |
const [download] = await Promise.all([ |
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 { defineConfig, devices } from '@playwright/test'; | |
export default defineConfig({ | |
use: { | |
baseURL: 'http://localhost:3000/', | |
}, | |
projects: [ | |
// Setup project | |
{ | |
name: 'setup', |
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 { test as setup } from '@playwright/test'; | |
const authFile = '.auth/user.json'; | |
setup('authenticate', async ({ page }) => { | |
// skip setup if environment variables for AAD creds are not set | |
setup.skip(!process.env.AADUSERNAME || !process.env.AADPASSWORD, 'AADUSERNAME and AADPASSWORD environment variables must be set'); | |
await page.goto(''); | |
// Sign in using creds from env variables |
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
// Use try catch block to handle the case where the consent dialog is shown for first login | |
try { | |
await dialog.waitForURL('**/Consent/**'); | |
await dialog.getByRole('button', { name: 'Yes' }).click(); | |
} catch (e) { | |
// Consent dialog was not shown | |
} |
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 { test, expect, Page, TestInfo } from '@playwright/test'; | |
test('performance test example', async ({ page }, TestInfo) => { | |
// Perform actions | |
await page.goto(`/`); | |
// Measure performance | |
await measurePerformance(page, TestInfo); | |
}); | |
async function measurePerformance(page: Page, TestInfo: TestInfo) { |
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
async function measureCartPerformance(page: Page, TestInfo: TestInfo) { | |
// Navigate to shopping cart | |
await page.goto(`/Carts`); | |
// Use Performance API to measure performance | |
// https://developer.mozilla.org/en-US/docs/Web/API/Performance/getEntriesByType | |
const performance = await page.evaluate(() => performance.getEntriesByType('navigation')); | |
// Get the first entry | |
const performanceTiming = performance[0]; | |
// Get the start to load event end time | |
const startToLoadEventEnd = performanceTiming.loadEventEnd - performanceTiming.startTime; |
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
jobs: | |
staging: | |
uses: ./.github/workflows/template.yml | |
secrets: inherit | |
with: | |
environmentName: staging | |
production: | |
needs: staging | |
uses: ./.github/workflows/template.yml |
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
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" |
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 { defineConfig, devices } from '@playwright/test'; | |
export default defineConfig({ | |
projects: [ | |
// Setup project | |
{ name: 'setup', testMatch: /.*\.setup\.ts/ }, | |
// Test project that requires authentication | |
{ | |
name: 'authenticated', | |
testMatch: /.authtests\.ts/, |
NewerOlder