Skip to content

Commit 03e7204

Browse files
committed
Fix visual tests
1 parent 28852b6 commit 03e7204

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

.github/workflows/visual-test.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
visual-test:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 60
17+
env:
18+
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/pw-browsers
19+
1720
steps:
1821
- name: Checkout 🛎️
1922
uses: actions/checkout@v3
@@ -25,7 +28,8 @@ jobs:
2528

2629
- name: Get yarn cache directory path
2730
id: yarn-cache-dir-path
28-
run: echo "::set-output name=dir::$(yarn cache dir)"
31+
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
32+
2933
- name: Setup yarn cache
3034
uses: actions/cache@v3
3135
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
@@ -36,8 +40,17 @@ jobs:
3640
yarn-
3741
3842
- name: Install Dependencies 📥
43+
env:
44+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
3945
run: yarn install
4046

47+
- name: Set up browser cache
48+
uses: actions/cache@v3
49+
with:
50+
path: |
51+
${{ github.workspace }}/pw-browsers
52+
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}
53+
4154
- name: Install Playwright Browsers
4255
run: yarn run playwright install --with-deps
4356
working-directory: packages/components
@@ -59,4 +72,4 @@ jobs:
5972
name: jupyter-ui-test
6073
path: |
6174
packages/components/test-assets/
62-
packages/components/tests-out/**/*-snapshots/*
75+
packages/components/src/**/*-snapshots/*

packages/components/playwright.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { PlaywrightTestConfig, devices } from '@playwright/test';
33
const config: PlaywrightTestConfig = {
44
forbidOnly: !!process.env.CI,
55
retries: process.env.CI ? 2 : 0,
6-
// testMatch: 'tests-out/**/*.test.js',
76
testMatch: 'src/**/*.test.ts',
87
webServer: {
98
command: 'yarn run start:ci',

packages/components/src/menu/menu.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { test, expect } from '@playwright/test';
66
test('Default', async ({ page }) => {
77
await page.goto('/iframe.html?id=components-menu--default');
88

9-
expect(
10-
await page.locator('#storybook-root > jp-menu').screenshot()
11-
).toMatchSnapshot('menu-default.png');
9+
expect(await page.locator('jp-menu').first().screenshot()).toMatchSnapshot(
10+
'menu-default.png'
11+
);
1212
});

packages/components/src/skeleton/skeleton.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
actions: { disabled: true }
1313
},
1414
decorators: [
15-
story => `<div style="display: block;">
15+
story => `<div data-testid="skeleton-container" style="display: block;">
1616
${story()}
1717
</div>`
1818
]

packages/components/src/skeleton/skeleton.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { test, expect } from '@playwright/test';
66
test('Default', async ({ page }) => {
77
await page.goto('/iframe.html?id=components-skeleton--default');
88

9-
expect(await page.locator('jp-skeleton').screenshot()).toMatchSnapshot(
10-
'skeleton-default.png'
11-
);
9+
expect(
10+
await page.getByTestId('skeleton-container').screenshot()
11+
).toMatchSnapshot('skeleton-default.png');
1212
});

0 commit comments

Comments
 (0)