Skip to content

Instantly share code, notes, and snippets.

@observethenoyes
observethenoyes / clientCertificates.spec.ts
Created August 5, 2025 15:56
Using a browser context, loading in base64 credentials for mTLS
import { expect, test } from '@playwright/test';
import fs from 'fs';
test('mTLS authentication test', async ({ browser }) => {
// Load client certificate from environment variable or file
let certBuffer;
if (process.env.CHECKLY_CERTIFICATE) {
certBuffer = Buffer.from(process.env.CHECKLY_CERTIFICATE, "base64");
} else {
const certPath = 'client.pem';
@observethenoyes
observethenoyes / visual.spec.ts
Last active September 4, 2025 15:20
Visual Regression Masking Example
const { expect, test } = require('@playwright/test')
test('wait for an element to become visible', async ({ page }) => {
await page.goto(process.env.ENVIRONMENT_URL || 'https://www.winzogames.us')
await page.waitForLoadState('networkidle');
// Use the "toHaveScreenshot" matcher to compare screenshots between check runs
// Don't forget to --update-snapshots on your first run!
await expect(page).toHaveScreenshot({
maxDiffPixelRatio: 0.2, //Define your thresholds here