From 8f9b6cf255907c5194fa43874996cd45ec250492 Mon Sep 17 00:00:00 2001 From: Egor Mostovoy Date: Wed, 25 Sep 2024 15:35:31 +0200 Subject: [PATCH] test: playwright cache (#312) --- .gitignore | 4 ++-- package.json | 1 + playwright/README.md | 3 ++- playwright/playwright.config.ts | 6 +++++- scripts/playwright-docker.sh | 2 ++ 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d26b6694..cec4f54f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,8 +13,8 @@ build pnpm-lock.yaml #Playwright -/playwright/playwright/.cache -/playwright-report +.cache* +playwright-report* /test-results # other files diff --git a/package.json b/package.json index 012b3e94..a7d87912 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "playwright:install": "playwright install --with-deps", "playwright": "playwright test --config=playwright/playwright.config.ts", "playwright:update": "npm run playwright -- -u", + "playwright:clear-cache": "rm -rf ./playwright/.cache", "playwright:docker": "./scripts/playwright-docker.sh 'npm run playwright'", "playwright:docker:update": "./scripts/playwright-docker.sh 'npm run playwright:update'", "playwright:docker:clear-cache": "./scripts/playwright-docker.sh clear-cache" diff --git a/playwright/README.md b/playwright/README.md index 6e76a768..0ed4c26c 100644 --- a/playwright/README.md +++ b/playwright/README.md @@ -118,6 +118,7 @@ - `npm run playwright:install` - install playwright browsers and dependencies - `npm run playwright` - run tests - `npm run playwright:update` - update screenshots +- `npm run playwright:clear-cache` - clear cache vite - `npm run playwright:docker` - run tests using docker - `npm run playwright:docker:update` - update screenshots using docker -- `npm run playwright:docker:clear-cache` - clear node_modules cache for docker container +- `npm run playwright:docker:clear-cache` - clear node_modules cache for docker container and clear cache vite diff --git a/playwright/playwright.config.ts b/playwright/playwright.config.ts index 424f9b52..92125e46 100644 --- a/playwright/playwright.config.ts +++ b/playwright/playwright.config.ts @@ -17,7 +17,10 @@ reporter.push( 'html', { open: process.env.CI ? 'never' : 'on-failure', - outputFolder: resolve(process.cwd(), 'playwright-report'), + outputFolder: resolve( + process.cwd(), + process.env.IS_DOCKER ? 'playwright-report-docker' : 'playwright-report', + ), }, ], ); @@ -53,6 +56,7 @@ const config: PlaywrightTestConfig = { /* Port to use for Playwright component endpoint. */ screenshot: 'only-on-failure', timezoneId: 'UTC', + ctCacheDir: process.env.IS_DOCKER ? '.cache-docker' : '.cache', ctViteConfig: { //@ts-ignore plugins: [ diff --git a/scripts/playwright-docker.sh b/scripts/playwright-docker.sh index 76747516..acc8ffd5 100755 --- a/scripts/playwright-docker.sh +++ b/scripts/playwright-docker.sh @@ -15,6 +15,7 @@ run_command() { $CONTAINER_TOOL run --rm --network host -it -w /work \ -v $(pwd):/work \ -v "$NODE_MODULES_CACHE_DIR:/work/node_modules" \ + -e IS_DOCKER=1 \ "$IMAGE_NAME:$IMAGE_TAG" \ /bin/bash -c "$1" } @@ -30,6 +31,7 @@ fi if [[ "$1" = "clear-cache" ]]; then rm -rf "$NODE_MODULES_CACHE_DIR" + rm -rf "./playwright/.cache-docker" exit 0 fi