Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using docker for visual testing #704

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Ignore files and directories generated by the build process
node_modules/
dist/
build/

# Ignore development and debugging files
*.log
*.tmp
*.bak
.vscode/

# Ignore specific files
.DS_Store
.env
.env.local
.env.*.local
.env.test
.env.production

# Ignore version control files
.git/
.gitignore

cypress
cla-signs
.verdaccio
.storybook
logs
4 changes: 4 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ runs:
with:
command: 'pnpm test.headless.ci'

- name: Run Visual Tests
shell: bash
run: 'pnpm test.headless.visual'

# - name: Publish to Chromatic
# uses: chromaui/action@v1
# # Chromatic GitHub Action options
Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM mcr.microsoft.com/playwright:v1.43.0-jammy

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

WORKDIR /opt

COPY package.json ./
COPY pnpm-lock.yaml ./

RUN pnpm install --frozen-lockfile

RUN pnpm playwright install --with-deps

COPY packages/kit-headless ./packages/kit-headless
COPY packages/kit-styled ./packages/kit-styled
COPY apps/component-tests ./apps/component-tests
COPY . .

#ENV DEBUG="pw:browser"
#ENV NX_VERBOSE_LOGGING=true
CMD ["pnpm", "test.headless.visual"]
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3'
services:
playwright:
build:
context: .
dockerfile: Dockerfile
image: playwright-tests
volumes:
- ./packages:/opt/packages
ports:
- '5713:5713'
# working_dir: /dev
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
"story.headless": "nx storybook headless",
"test.cli": "NODE_OPTIONS=--experimental-vm-modules nx test cli",
"test.headless": "nx component-test headless",
"test.visual.headless": "nx visual-test headless",
"test.headless.visual": "nx visual-test headless",
"test.pw.headless": "nx e2e headless",
"test.pw.headless.ci": "nx e2e headless",
"test.headless.ci": "nx component-test-ci headless",
"test.headless.ci.visual": "docker-compose up",
"test.utils": "nx test utils"
},
"packageManager": "[email protected]",
Expand Down
7 changes: 7 additions & 0 deletions packages/kit-headless/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineConfig({
...nxE2EPreset(__filename, { testDir: './src' }),
testMatch: '**/*.test.ts',
timeout: 30000,
reporter: [['line']],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL,
Expand All @@ -45,6 +46,12 @@ export default defineConfig({
name: 'visual',
use: { ...devices['Desktop Chrome'] },
grep: /@Visual.*/,

expect: {
toHaveScreenshot: {
maxDiffPixelRatio: 0.02,
},
},
},

// {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading