old-portfolio-site/tests/example.spec.ts

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-03-16 09:12:50 +00:00
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});
test('get started link', async ({ page }) => {
await page.goto('/');
// Click the Look at my code link.
await page.getByRole('link', { name: 'Look at my code' }).click();
// Click the get cv link.
await page.getByRole('link', { name: 'Get my CV' }).click();
// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
// Blog tests
test('Blog tests', async ({ page }) => {
await page.goto('/blog');
await page.click('a[href="/about"]');
expect(page.url()).toBe('http://localhost:513/about');
});
beforeAll(async () => {
browser = await chromium.launch();
});
afterAll(async () => {
await browser.close();
});
beforeEach(async () => {
page = await browser.newPage();
await page.goto('http://localhost:5000/skills'); // replace with the URL of your skills page
});
afterEach(async () => {
await page.close();
});
it('should display the correct skill levels', async () => {
const skills = await page.$$eval('.chip', (elements) => elements.map((el) => el.textContent));
for (const skill of skills) {
expect(skill).toMatch(/^(Proficient|Experienced|Limited Experience):/);
}
});