Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ jobs:
run: pnpm run typecheck
- name: Check to build passed
run: pnpm run build
- name: Install Playwright browsers
run: pnpm exec playwright install --with-deps chromium firefox webkit
- name: Check to test passed
run: pnpm run test
7 changes: 5 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ This file provides guidance to AI coding agents when working with code in this r

## Testing

- **環境**: jsdom(vitest.config.tsで設定)
- **環境**: Vitest browser mode(Playwright provider)で Chromium / Firefox / WebKit の実ブラウザ上で全テストを実行する(vitest.config.tsで設定)。MutationObserverのレコード配信やマイクロタスクの実行タイミングはエンジンごとに差があり得るため、3エンジンすべてで通すことを前提にする
- **ブラウザの準備**: 初回は `pnpm exec playwright install chromium firefox webkit` でブラウザを取得する
- **特定エンジンだけ実行**: `pnpm vitest run --project chromium`
- **Node専用APIを使わない**: テストはブラウザで動くため、`node:*` モジュール(`node:timers/promises` 等)はimportできない。待機は `src/index.test.ts` のローカル `delay` を使う
- **型テスト**: `*.test-d.ts`ファイルで`expectTypeOf`を使用(vitest typecheck有効)
- **DOMテストの注意**: jsdomはテスト間でグローバルDOMを共有するため、各テストでサンドボックス要素(`test-sandbox`)をbeforeEachでクリーン・再生成している(`describe.shuffle`で順序非依存を保証)
- **DOMテストの注意**: browser modeはテストファイルごとに別のiframeで実行するため、ファイルをまたいだDOMやグローバル変数の衝突は起きない。一方で同じファイル内のテストは1つのdocumentを共有するため、各テストでサンドボックス要素(`test-sandbox`)をbeforeEachでクリーン・再生成している(`describe.shuffle`で順序非依存を保証)
- テストタイムアウトは50秒に設定

## Code Style
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@
},
"devDependencies": {
"@biomejs/biome": "2.5.14",
"@types/jsdom": "30.0.0",
"@vitest/browser-playwright": "5.0.2",
"@vitest/coverage-v8": "5.0.2",
"@vitest/ui": "5.0.2",
"jsdom": "30.1.1",
"playwright": "1.63.0",
"typescript": "6.0.3",
"unbuild": "3.6.1",
"vitest": "5.0.2"
},
"scripts": {
"test": "vitest",
"test-ci": "vitest run",
"coverage": "vitest --coverage --ui",
"coverage": "vitest --coverage --ui --project chromium",
"biome": "biome check --write ./src",
"typecheck": "tsc --noEmit",
"build": "unbuild",
Expand Down
Loading
Loading