Skip to content

Instantly share code, notes, and snippets.

@itaditya
Created March 5, 2022 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itaditya/9d57918cc9c94e2875d75869e079e519 to your computer and use it in GitHub Desktop.
Save itaditya/9d57918cc9c94e2875d75869e079e519 to your computer and use it in GitHub Desktop.
Demo Auth Storage
import { test } from '@playwright/test';
test.describe('When user logged-out', () => {
test('Test login page @flow=auth', async ({ page, context }) => {
await page.goto('https://remix-jokes.lol/login');
await page.locator('input[name="username"]').fill('itaditya');
await page.locator('input[name="password"]').fill('random');
await Promise.all([page.waitForNavigation(), page.locator('text=Submit').click()]);
context.storageState({
path: 'jokesAuth.json',
});
});
});
test.describe('When user logged-in @flow=app', () => {
test.use({
storageState: 'jokesAuth.json',
});
test('Test jokes page', async ({ page }) => {
await page.goto('https://remix-jokes.lol/jokes');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment