Last active
August 30, 2024 21:07
-
-
Save dadamssg/390014e8b7b766093c84f81466468009 to your computer and use it in GitHub Desktop.
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
import { expect, test } from '@playwright/test' | |
import { login } from './auth' | |
test('can view contacts', async ({ page }) => { | |
await login({ page }) | |
// remix is running on port 3000 | |
await fetch('http://localhost:3000/app/playwright', { | |
method: 'POST', | |
headers: { 'content-type': 'application/json' }, | |
body: JSON.stringify({ | |
// the api I'm pulling data from is running on port 6000. This is what I need to mock | |
url: 'http://localhost:6000/people', | |
method: 'post', | |
once: true, | |
response: { | |
data: [ | |
{ | |
id: 'abc', | |
firstname: 'Sally', | |
lastname: 'Rogers', | |
email: '[email protected]', | |
}, | |
], | |
}, | |
}), | |
}) | |
await page.goto('/app/contacts') | |
const name = page.getByText('Sally Rogers') | |
await expect(name).toHaveText('Sally Rogers') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment