Skip to content

Commit

Permalink
Add playwright image snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Nov 9, 2024
1 parent fcc9a99 commit 8fb1def
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/wc-lit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"start": "vite",
"build": "vite build",
"preview": "vite preview",
"test": "playwright test"
"test": "playwright test",
"test:ui": "playwright test --ui"
},
"dependencies": {
"@responsive-image/cdn": "workspace:*",
Expand Down
2 changes: 2 additions & 0 deletions apps/wc-lit/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { defineConfig, devices } from '@playwright/test';
*/
export default defineConfig({
testDir: './tests',
snapshotPathTemplate:
'{testDir}/__screenshots__{/projectName}/{testFilePath}/{arg}{ext}',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/wc-lit/tests/responsive-image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test('responsive layout', async ({ page }) => {
'src',
new RegExp(`/assets/aurora-[0-9]+w(-[a-zA-Z0-9-_]+)?.jpg`),
);
await expect(img).toHaveScreenshot();

const picture = page.locator('[data-test-local-image="responsive"] picture');

Expand Down Expand Up @@ -44,6 +45,7 @@ test('fixed layout', async ({ page }) => {
);
await expect(img).toHaveAttribute('width', '320');
await expect(img).toHaveAttribute('height', /213/);
await expect(img).toHaveScreenshot();

const picture = page.locator('[data-test-local-image="fixed"] picture');

Expand Down Expand Up @@ -80,6 +82,7 @@ test('fixed layout w/ aspect', async ({ page }) => {
);
await expect(img).toHaveAttribute('width', '320');
await expect(img).toHaveAttribute('height', '480');
await expect(img).toHaveScreenshot();

const picture = page.locator('[data-test-local-image="fixed"] picture');

Expand Down

0 comments on commit 8fb1def

Please sign in to comment.