-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.spec.ts
29 lines (27 loc) · 1015 Bytes
/
index.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { test, expect } from '@playwright/test';
test.describe('home page', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('has name in title', async ({ page }) => {
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Home • Chris Vaillancourt/);
});
test('has heading with name and title', async ({ page }) => {
const heading = page.getByRole('heading', {
name: `Hi! I'm Chris, a full stack software engineer`,
});
await expect(heading).toBeVisible();
});
test('has posts heading', async ({ page }) => {
const postsHeading = await page.getByRole('heading', { name: 'Posts' });
await expect(postsHeading).toBeVisible();
});
test('has recent posts', async ({ page }) => {
const postsList = await page.getByLabel('Blog post list');
await expect(postsList).toBeVisible();
const posts = postsList.getByRole('listitem');
const postsText = await posts.allTextContents();
expect(postsText.length).toBeGreaterThan(6);
});
});