Skip to content

Commit 0520a0a

Browse files
authored
test: playwright cache (#237)
1 parent d62c24c commit 0520a0a

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ build
1313
storybook-static
1414

1515
#Playwright
16-
/playwright/playwright/.cache
17-
/playwright-report
18-
/test-results
16+
.cache*
17+
playwright-report*
18+
/test-results

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"playwright:install": "playwright install --with-deps",
3939
"playwright": "playwright test --config=playwright/playwright.config.ts",
4040
"playwright:update": "npm run playwright -- -u",
41+
"playwright:clear-cache": "rm -rf ./playwright/.cache",
4142
"playwright:docker": "./scripts/playwright-docker.sh 'npm run playwright'",
4243
"playwright:docker:update": "./scripts/playwright-docker.sh 'npm run playwright:update'",
4344
"playwright:docker:clear-cache": "./scripts/playwright-docker.sh clear-cache"

playwright/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ npm run playwright:docker
104104
- `npm run playwright:install` - install playwright browsers and dependencies
105105
- `npm run playwright` - run tests
106106
- `npm run playwright:update` - update screenshots
107+
- `npm run playwright:clear-cache` - clear cache vite
107108
- `npm run playwright:docker` - run tests using docker
108109
- `npm run playwright:docker:update` - update screenshots using docker
109-
- `npm run playwright:docker:clear-cache` - clear node_modules cache for docker container
110+
- `npm run playwright:docker:clear-cache` - clear node_modules cache for docker container and clear cache vite

playwright/playwright.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ reporter.push(
1616
'html',
1717
{
1818
open: process.env.CI ? 'never' : 'on-failure',
19-
outputFolder: resolve(process.cwd(), 'playwright-report'),
19+
outputFolder: resolve(
20+
process.cwd(),
21+
process.env.IS_DOCKER ? 'playwright-report-docker' : 'playwright-report',
22+
),
2023
},
2124
],
2225
);
@@ -52,6 +55,7 @@ const config: PlaywrightTestConfig = {
5255
/* Port to use for Playwright component endpoint. */
5356
screenshot: 'only-on-failure',
5457
timezoneId: 'UTC',
58+
ctCacheDir: process.env.IS_DOCKER ? '.cache-docker' : '.cache',
5559
ctViteConfig: {
5660
plugins: [react()],
5761
resolve: {

scripts/playwright-docker.sh

Lines changed: 2 additions & 0 deletions
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

0 commit comments

Comments
 (0)