Skip to content

Commit 3091f98

Browse files
committed
enable chromatic<>playwright instegration
1 parent acdddc7 commit 3091f98

File tree

7 files changed

+560
-25
lines changed

7 files changed

+560
-25
lines changed

.github/workflows/chromatic.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# Workflow name
44
name: Chromatic Publish and Testing
5-
65
# Event for the workflow
76
on:
87
pull_request:
@@ -18,6 +17,10 @@ on:
1817
- ".storybook/**/*"
1918
- "tailwind.config.ts"
2019
- "src/styles/**/*"
20+
branches-ignore:
21+
- "master"
22+
- "staging"
23+
- "e2e-tests" # TODO: remove e2e-tests (testing branch)
2124

2225
# List of jobs
2326
jobs:
@@ -39,7 +42,7 @@ jobs:
3942
uses: actions/setup-node@v3
4043
with:
4144
node-version: 20
42-
cache: 'pnpm'
45+
cache: "pnpm"
4346
- name: Install deps
4447
# 👇 Install dependencies with the same package manager used in the project (replace it as needed), e.g. yarn, npm, pnpm
4548
run: pnpm install

.github/workflows/playwright.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
branches: [master, staging, e2e-tests] # TODO: remove e2e-tests (testing branch)
77
jobs:
8-
test:
8+
playwright:
99
runs-on: ubuntu-latest
1010
env:
1111
CI: true
@@ -48,3 +48,33 @@ jobs:
4848
name: playwright-report
4949
path: tests/e2e/__report__/
5050
retention-days: 7
51+
52+
chromatic:
53+
name: Run Chromatic
54+
needs: playwright
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
60+
- uses: actions/setup-node@v4
61+
with:
62+
node-version: 22.12.0
63+
- name: Setup pnpm
64+
uses: pnpm/action-setup@v2
65+
66+
- name: Install dependencies
67+
run: pnpm install
68+
69+
- name: Download Playwright test results
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: playwright-report
73+
path: tests/e2e/__report__/
74+
75+
- name: Run Chromatic
76+
uses: chromaui/action@latest
77+
with:
78+
playwright: true
79+
projectToken: fee8e66c9916
80+
env: CHROMATIC_ARCHIVE_LOCATION=tests/e2e/__results__

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ src/data/crowdin/bucketsAwaitingReviewReport.csv
6363

6464
# Storybook
6565
build-storybook.log
66+
build-archive.log
6667
storybook-static

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"storybook": "storybook dev -p 6006",
1717
"build-storybook": "storybook build",
1818
"build-storybook:chromatic": "storybook build --test",
19-
"chromatic": "chromatic --project-token fee8e66c9916",
19+
"chromatic": "CHROMATIC_ARCHIVE_LOCATION=tests/e2e/__results__ chromatic --project-token fee8e66c9916",
2020
"crowdin-clean": "rm -rf .crowdin && mkdir .crowdin",
2121
"crowdin-import": "ts-node src/scripts/crowdin-import.ts",
2222
"markdown-checker": "ts-node -O '{ \"module\": \"commonjs\" }' src/scripts/markdownChecker.ts",
@@ -97,6 +97,7 @@
9797
"yaml-loader": "^0.8.0"
9898
},
9999
"devDependencies": {
100+
"@chromatic-com/playwright": "^0.12.4",
100101
"@chromatic-com/storybook": "1.5.0",
101102
"@netlify/plugin-nextjs": "^5.10.0",
102103
"@playwright/test": "^1.52.0",
@@ -121,8 +122,9 @@
121122
"@typescript-eslint/eslint-plugin": "^6.19.0",
122123
"@typescript-eslint/parser": "^6.19.0",
123124
"autoprefixer": "^10.4.19",
124-
"chromatic": "10.9.6",
125+
"chromatic": "12.0.0",
125126
"decompress": "^4.2.1",
127+
"dotenv": "^16.5.0",
126128
"eslint": "^8.45.0",
127129
"eslint-config-next": "^14.2.2",
128130
"eslint-config-prettier": "9.1.0",

playwright.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
import type { ChromaticConfig } from "@chromatic-com/playwright"
12
import { defineConfig, devices } from "@playwright/test"
23

34
import "dotenv/config"
45

5-
export default defineConfig({
6+
export default defineConfig<ChromaticConfig>({
67
testDir: "./tests/e2e",
78
outputDir: "./tests/e2e/__results__",
89
fullyParallel: true,
910
forbidOnly: !!process.env.CI,
1011
retries: process.env.CI ? 2 : 0,
1112
workers: process.env.CI ? 1 : undefined,
12-
reporter: process.env.CI
13-
? "dot"
14-
: [["html", { outputFolder: "./tests/e2e/__report__" }]],
13+
reporter: [["html", { outputFolder: "./tests/e2e/__report__" }]],
1514
use: {
1615
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || "http://localhost:3000",
1716
trace: "on-first-retry",
1817
screenshot: "only-on-failure",
18+
19+
// chromatic settings
20+
disableAutoSnapshot: true,
1921
},
2022
projects: [
2123
/* Test against desktop browsers */

0 commit comments

Comments
 (0)