Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add Playwright tests #7

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

WIP: Add Playwright tests #7

wants to merge 1 commit into from

Conversation

wlsf82
Copy link
Owner

@wlsf82 wlsf82 commented Dec 20, 2024

No description provided.

@wlsf82 wlsf82 force-pushed the pw branch 4 times, most recently from 71d83d0 to 54f2bde Compare December 21, 2024 01:21
test('shows a promotional banner', async ({ page }) => {
const banner = await page.locator('#promotional-banner')
expect(await banner).toBeVisible()
expect(await banner.innerText()).toContain('📣 Get to know the Cypress, from Zero to the Cloud course!')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be replaced by await expect(banner).toHaveText('📣 Get to know the Cypress, from Zero to the Cloud course!')

expect(await banner.innerText()).toContain('📣 Get to know the Cypress, from Zero to the Cloud course!')

const link = await banner.locator('a')
expect(await link.getAttribute('target')).toEqual('_blank')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be replaced by await expect(link).toHaveAttribute('target', '_blank')

eslint-plugin-playwright auto-fix this one

Comment on lines +21 to +22
const banner = await page.locator('#promotional-banner')
expect(await banner).toBeVisible()
Copy link

@jfgreffier jfgreffier Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, you'll need to await the expect() but not the Locator.

You can think of Locator as a pointer to an element that will be used when needed. When you create the Locator, the element may or may not be here. We don't care (yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants