Skip to content

Replace Happy DOM with Vitest Browser Mode #250

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:

- name: Install dependencies
run: yarn --immutable
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true

- name: Build package
run: yarn build
Expand Down Expand Up @@ -91,6 +93,15 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}

- name: Cache ~/.cache/ms-playwright
id: playwright-cache
uses: actions/cache@v4
env:
cache-name: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}

- name: Use Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -102,5 +113,9 @@ jobs:
- name: Install dependencies
run: yarn --immutable

- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: yarn workspace react-clock playwright install chromium-headless-shell

- name: Run tests
run: yarn unit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
!**/.yarn/versions

# Project-generated directories and files
__screenshots__
coverage
dist
node_modules
Expand Down
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
enableScripts: false

logFilters:
- code: YN0076
level: discard
Expand Down
6 changes: 4 additions & 2 deletions packages/react-clock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@
"@types/node": "*",
"@types/react": "*",
"@types/react-dom": "*",
"@vitest/browser": "^3.2.3",
"cpy-cli": "^5.0.0",
"happy-dom": "^15.10.2",
"playwright": "^1.51.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.5.2",
"vitest": "^3.2.3"
"vitest": "^3.2.3",
"vitest-browser-react": "^1.0.1"
},
"peerDependencies": {
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/react-clock/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"skipLibCheck": true,
"strict": true,
"target": "es2018",
"types": ["@vitest/browser/matchers"],
"verbatimModuleSyntax": true
},
"exclude": ["dist"]
Expand Down
7 changes: 6 additions & 1 deletion packages/react-clock/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
environment: 'happy-dom',
browser: {
enabled: true,
headless: true,
instances: [{ browser: 'chromium' }],
provider: 'playwright',
},
setupFiles: 'vitest.setup.ts',
watch: false,
},
Expand Down
Loading
Loading