Skip to content

Commit

Permalink
feat: unified e2e tests for Checkly and playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Nov 19, 2023
1 parent 4d880be commit afa53f5
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 90 deletions.
50 changes: 0 additions & 50 deletions __checks__/Sanity.spec.ts

This file was deleted.

8 changes: 7 additions & 1 deletion checkly.config.ts
Expand Up @@ -16,9 +16,15 @@ export const config = defineConfig({
locations: ['us-east-1', 'eu-west-1'],
tags: ['website'],
runtimeId: '2023.09',
environmentVariables: [
{
key: 'ENVIRONMENT_URL',
value: 'https://google.com',
},
],
browserChecks: {
frequency: Frequency.EVERY_24H,
testMatch: '**/__checks__/**/*.spec.ts',
testMatch: '**/tests/e2e/**/*.check.spec.ts',
alertChannels: [emailChannel],
},
},
Expand Down
39 changes: 0 additions & 39 deletions tests/e2e/Navigation.spec.ts
Expand Up @@ -3,45 +3,6 @@ import { expect, test } from '@playwright/test';

test.describe('Navigation', () => {
test.describe('Static pages', () => {
test('should display the homepage', async ({ page }) => {
await page.goto('/');

await expect(
page.getByRole('heading', {
name: 'Boilerplate code for your Nextjs project with Tailwind CSS',
}),
).toBeVisible();
});

test('should navigate to the about page', async ({ page }) => {
await page.goto('/');

await page.getByRole('link', { name: 'About' }).click();
await expect(page).toHaveURL('/about');

await expect(
page.getByText('Lorem ipsum dolor sit amet', { exact: false }),
).toHaveCount(2);
});

test('should navigate to the portfolio page', async ({ page }) => {
await page.goto('/');

await page.getByRole('link', { name: 'Portfolio' }).click();
await expect(page).toHaveURL('/portfolio');

await expect(page.locator('main').getByRole('link')).toHaveCount(6);
});

test('should navigate to the blog page', async ({ page }) => {
await page.goto('/');

await page.getByRole('link', { name: 'Blog' }).click();
await expect(page).toHaveURL('/blog');

await expect(page.locator('main').getByRole('link')).toHaveCount(10);
});

test('should take screenshot of the homepage', async ({ page }) => {
await page.goto('/');

Expand Down
50 changes: 50 additions & 0 deletions tests/e2e/Sanity.check.spec.ts
@@ -0,0 +1,50 @@
import { expect, test } from '@playwright/test';

if (process.env.ENVIRONMENT_URL) {
test.use({
baseURL: process.env.ENVIRONMENT_URL,
});
}

test.describe('Sanity', () => {
test.describe('Static pages', () => {
test('should display the homepage', async ({ page }) => {
await page.goto('/');

await expect(
page.getByRole('heading', {
name: 'Boilerplate code for your Nextjs project with Tailwind CSS',
}),
).toBeVisible();
});

test('should navigate to the about page', async ({ page }) => {
await page.goto('/');

await page.getByRole('link', { name: 'About' }).click();
await expect(page).toHaveURL('/about');

await expect(
page.getByText('Lorem ipsum dolor sit amet', { exact: false }),
).toHaveCount(2);
});

test('should navigate to the portfolio page', async ({ page }) => {
await page.goto('/');

await page.getByRole('link', { name: 'Portfolio' }).click();
await expect(page).toHaveURL('/portfolio');

await expect(page.locator('main').getByRole('link')).toHaveCount(6);
});

test('should navigate to the blog page', async ({ page }) => {
await page.goto('/');

await page.getByRole('link', { name: 'Blog' }).click();
await expect(page).toHaveURL('/blog');

await expect(page.locator('main').getByRole('link')).toHaveCount(10);
});
});
});

0 comments on commit afa53f5

Please sign in to comment.