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'; | |
const config: PlaywrightTestConfig = { | |
// register global setup for login | |
globalSetup: require.resolve('./global-setup'), | |
use: { | |
// Tell all tests to load signed-in state from 'storageState.json'. | |
storageState: 'storageState.json' | |
} | |
}; |
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 ({ browser }) => { | |
const page = await browser.newPage(); | |
await page.goto(''); | |
// Sign in using creds from env variables | |
const dialogPromise = page.waitForEvent('popup'); | |
await page.getByText('LOGIN').click(); |
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/, |
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
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
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
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
// 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 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
import { defineConfig, devices } from '@playwright/test'; | |
export default defineConfig({ | |
use: { | |
baseURL: 'http://localhost:3000/', | |
}, | |
projects: [ | |
// Setup project | |
{ | |
name: 'setup', |