Skip to content

Commit

Permalink
test(spinner): refactor tests to use beforeEach for page navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
max-umain committed Dec 17, 2024
1 parent 4dcf97e commit ca417e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { expect } from '@playwright/test';
const componentTestPath = 'src/components/spinner/test/inverted/darkmode/index.html';

test.describe.parallel('tds-spinner-inverted-darkmode', () => {
test('renders inverted spinner correctly', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders inverted spinner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { expect } from '@playwright/test';
const componentTestPath = 'src/components/spinner/test/inverted/lightmode/index.html';

test.describe.parallel('tds-spinner-inverted-lightmode', () => {
test('renders inverted spinner correctly', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders inverted spinner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { expect } from '@playwright/test';
const componentTestPath = 'src/components/spinner/test/standard/darkmode/index.html';

test.describe.parallel('tds-spinner-standard-darkmode', () => {
test('renders basic spinner correctly', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders basic spinner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { expect } from '@playwright/test';
const componentTestPath = 'src/components/spinner/test/standard/lightmode/index.html';

test.describe.parallel('tds-spinner-standard-lightmode', () => {
test('renders basic spinner correctly', async ({ page }) => {
test.beforeEach(async ({ page }) => {
await page.goto(componentTestPath);
});

test('renders basic spinner correctly', async ({ page }) => {
/* Check diff on screenshot */
await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });
});

test('Check if animation is present', async ({ page }) => {
await page.goto(componentTestPath);

const spinner = page.locator('tds-spinner:first-child circle');
const spinnerStyle = await spinner.evaluate((style) => getComputedStyle(style).animationName);
expect(spinnerStyle).toBe('dash');
Expand Down

0 comments on commit ca417e0

Please sign in to comment.