Skip to content

Commit 218f1c4

Browse files
authored
test: playwright cache (#1029)
* test: playwright cache * fix: add mask test map * fix: lint
1 parent 9f5f2b9 commit 218f1c4

14 files changed

+24
-18
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ node_modules
1919
.env
2020
.env.development
2121
/test-results/
22-
/playwright-report/
22+
playwright-report*
2323
/blob-report/
24-
/playwright/playwright/.cache/
24+
.cache*

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"test:watch": "jest --watchAll",
8181
"playwright": "playwright test --config=playwright/playwright.config.ts",
8282
"playwright:update": "npm run playwright -- -u",
83+
"playwright:clear-cache": "rm -rf ./playwright/.cache",
8384
"playwright:docker": "./scripts/playwright-docker.sh 'npm run playwright'",
8485
"playwright:docker:update": "./scripts/playwright-docker.sh 'npm run playwright:update'",
8586
"playwright:docker:clear-cache": "./scripts/playwright-docker.sh clear-cache",

playwright/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
- `npm run playwright:install` - install playwright browsers and dependencies
133133
- `npm run playwright` - run tests
134134
- `npm run playwright:update` - update screenshots
135+
- `npm run playwright:clear-cache` - clear cache vite
135136
- `npm run playwright:docker` - run tests using docker
136137
- `npm run playwright:docker:update` - update screenshots using docker
137-
- `npm run playwright:docker:clear-cache` - clear node_modules cache for docker container
138+
- `npm run playwright:docker:clear-cache` - clear node_modules cache for docker container and clear cache vite

playwright/playwright.config.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ reporter.push(
1818
'html',
1919
{
2020
open: process.env.CI ? 'never' : 'on-failure',
21-
outputFolder: resolve(process.cwd(), 'playwright-report'),
21+
outputFolder: resolve(
22+
process.cwd(),
23+
process.env.IS_DOCKER ? 'playwright-report-docker' : 'playwright-report',
24+
),
2225
},
2326
],
2427
);
@@ -54,6 +57,7 @@ const config: PlaywrightTestConfig = {
5457
/* Port to use for Playwright component endpoint. */
5558
screenshot: 'only-on-failure',
5659
timezoneId: 'UTC',
60+
ctCacheDir: process.env.IS_DOCKER ? '.cache-docker' : '.cache',
5761
ctViteConfig: {
5862
publicDir: pathFromRoot('.storybook/public'),
5963
json: {

scripts/playwright-docker.sh

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ run_command() {
1515
$CONTAINER_TOOL run --rm --network host -it -w /work \
1616
-v $(pwd):/work \
1717
-v "$NODE_MODULES_CACHE_DIR:/work/node_modules" \
18+
-e IS_DOCKER=1 \
1819
"$IMAGE_NAME:$IMAGE_TAG" \
1920
/bin/bash -c "$1"
2021
}
@@ -30,6 +31,7 @@ fi
3031

3132
if [[ "$1" = "clear-cache" ]]; then
3233
rm -rf "$NODE_MODULES_CACHE_DIR"
34+
rm -rf "./playwright/.cache-docker"
3335
exit 0
3436
fi
3537

src/blocks/Map/__tests__/Map.visual.test.tsx

+12-14
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,28 @@ import {test} from '../../../../playwright/core/index';
44

55
import {Default, Direction, MapsTypes, Size} from './helpers';
66

7-
const DEFAULT_MAP_DELAY = 20 * 1000;
8-
97
test.describe('Map', () => {
10-
test.skip('render stories <Default>', async ({mount, expectScreenshot, delay}) => {
8+
test('render stories <Default>', async ({mount, expectScreenshot, page}) => {
119
await mount(<Default />);
12-
await delay(DEFAULT_MAP_DELAY);
13-
await expectScreenshot({skipTheme: 'dark'});
10+
11+
await expectScreenshot({skipTheme: 'dark', mask: [page.locator('.pc-map')]});
1412
});
1513

16-
test.skip('render stories <Size>', async ({mount, expectScreenshot, delay}) => {
14+
test('render stories <Size>', async ({mount, expectScreenshot, page}) => {
1715
await mount(<Size />);
18-
await delay(DEFAULT_MAP_DELAY);
19-
await expectScreenshot({skipTheme: 'dark'});
16+
17+
await expectScreenshot({skipTheme: 'dark', mask: [page.locator('.pc-map')]});
2018
});
2119

22-
test.skip('render stories <Direction>', async ({mount, expectScreenshot, delay}) => {
20+
test('render stories <Direction>', async ({mount, expectScreenshot, page}) => {
2321
await mount(<Direction />);
24-
await delay(DEFAULT_MAP_DELAY);
25-
await expectScreenshot({skipTheme: 'dark'});
22+
23+
await expectScreenshot({skipTheme: 'dark', mask: [page.locator('.pc-map')]});
2624
});
2725

28-
test.skip('render stories <MapsTypes>', async ({mount, expectScreenshot, delay}) => {
26+
test('render stories <MapsTypes>', async ({mount, expectScreenshot, page}) => {
2927
await mount(<MapsTypes />);
30-
await delay(DEFAULT_MAP_DELAY);
31-
await expectScreenshot({skipTheme: 'dark'});
28+
29+
await expectScreenshot({skipTheme: 'dark', mask: [page.locator('.pc-map')]});
3230
});
3331
});

0 commit comments

Comments
 (0)