Skip to content

test: remove jsdom by running all DOM tests in a real browser - #1002

Merged
ocavue merged 1 commit into
masterfrom
remove-jsdom
Jul 31, 2026
Merged

ocavue merged 1 commit into
masterfrom
remove-jsdom

Conversation

@ocavue

@ocavue ocavue commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The only jsdom test was parsePageMeta, whose DOMParser always runs in a browser in production, so packages/core gets a browser project like apps/desktop and jsdom leaves the dependency tree entirely.

Summary by CodeRabbit

  • Testing

    • Core browser tests now run in real Chromium or WebKit browsers through Playwright.
    • Core Node-based tests run in a dedicated Node environment.
    • Test commands now execute both browser and Node projects.
    • Updated test discovery and project configuration for more consistent local and CI runs.
  • Documentation

    • Updated testing guidance to distinguish browser-based JavaScript tests from Node and Rust tests.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The repository now uses explicit Vitest projects. Core tests run in separate Playwright browser and Node projects. Testing documentation and meta-scrape comments describe the browser requirement for DOM-dependent tests.

Changes

Vitest testing setup

Layer / File(s) Summary
Workspace project registration
vitest.config.ts
Vitest now lists desktop, extension, core, database, and utility projects explicitly.
Core browser and Node projects
packages/core/vitest.browser.config.ts, packages/core/vitest.node.config.ts, packages/core/package.json
Core runs browser tests with Playwright and Node tests with separate project configurations. The package replaces jsdom with Playwright dependencies.
Testing guidance and browser requirement
docs/contributing/testing.md, packages/core/src/actions/meta-scrape.ts
Documentation states that DOM tests use Vitest browser mode. The meta-scrape documentation identifies real-browser execution.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing jsdom with real-browser execution for DOM tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-jsdom

Comment @coderabbitai help to get the list of available commands.

@ocavue ocavue changed the title test: remove jsdom by running meta-scrape tests in a real browser test: remove jsdom by running all DOM tests in a real browser Jul 31, 2026
@ocavue
ocavue marked this pull request as ready for review July 31, 2026 03:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/package.json`:
- Line 13: Ensure the targeted test command defined by the package.json test
script passes with a zero exit status by installing the missing Playwright
Chromium executable via pnpm exec playwright install, then rerunning the core
Vitest command. Do not treat the existing pnpm check warnings as failures.

In `@packages/core/vitest.browser.config.ts`:
- Around line 10-17: Add fileParallelism: false to the top-level Vitest
configuration in both the browser and node core project configs, alongside the
existing sequence/retry settings, so core test files continue executing
serially. Do not alter the existing browser or test execution settings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd3ff844-25b2-4304-8a43-463a87eaecd8

📥 Commits

Reviewing files that changed from the base of the PR and between 2528cf3 and 5b37305.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • docs/contributing/testing.md
  • packages/core/package.json
  • packages/core/src/actions/meta-scrape.test.tsx
  • packages/core/src/actions/meta-scrape.ts
  • packages/core/vitest.browser.config.ts
  • packages/core/vitest.node.config.ts
  • vitest.config.ts
💤 Files with no reviewable changes (1)
  • packages/core/src/actions/meta-scrape.test.tsx

"scripts": {
"typecheck": "tsc --noEmit",
"test": "vitest run"
"test": "vitest run --config ../../vitest.config.ts --project core-browser --project core-node"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

pnpm check
(
  cd packages/core
  pnpm test
)

Repository: team-reflect/reflect-open

Length of output: 34236


Make the targeted core test command pass before merge.

pnpm check completes with warnings, but cd packages/core && pnpm test fails because the Playwright Chromium executable is missing. Run pnpm exec playwright install, then rerun the test command and require a zero exit status.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/package.json` at line 13, Ensure the targeted test command
defined by the package.json test script passes with a zero exit status by
installing the missing Playwright Chromium executable via pnpm exec playwright
install, then rerunning the core Vitest command. Do not treat the existing pnpm
check warnings as failures.

Source: Coding guidelines

Comment on lines +10 to +17
sequence: { groupOrder: 100 },
retry: process.env.CI ? 3 : 0,
slowTestThreshold: 10_000,
browser: {
enabled: true,
provider: playwright(),
headless: !process.env.DEBUG,
instances: [{ browser: browserName }],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- candidate files ---'
fd -t f 'vitest.*\.config\.(ts|js|mjs|cjs)$' . || true

printf '%s\n' '--- core config files ---'
for file in packages/core/vitest.browser.config.ts packages/core/vitest.node.config.ts vitest.config.ts; do
  if [ -f "$file" ]; then
    printf '\n--- %s ---\n' "$file"
    cat -n "$file"
  fi
done

printf '%s\n' '--- Vitest configuration references ---'
rg -n --hidden --glob '!node_modules' --glob '!dist' \
  'fileParallelism|sequence\s*:|vitest\.browser|vitest\.node|defineConfig|projects' \
  packages/core vitest.config.ts package.json pnpm-workspace.yaml 2>/dev/null || true

Repository: team-reflect/reflect-open

Length of output: 5233


🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- Vitest versions and test scripts ---'
rg -n --hidden --glob '!node_modules' --glob '!dist' \
  '"vitest"|"test"|"check"' \
  package.json pnpm-lock.yaml packages/core/package.json apps/desktop/package.json 2>/dev/null | head -160

printf '%s\n' '--- core test files and likely shared-state APIs ---'
files=$(fd -t f -e ts -e tsx '.*\.test\.(ts|tsx)$' packages/core/src | sort)
printf '%s\n' "$files" | wc -l
rg -n --hidden \
  'describe\.parallel|test\.parallel|it\.parallel|beforeAll|afterAll|beforeEach|afterEach|open\(|Database|sqlite|fs\.|writeFile|mkdir|rm\(|process\.env|globalThis|shared|singleton' \
  packages/core/src --glob '*.test.ts' --glob '*.test.tsx' 2>/dev/null | head -240

printf '%s\n' '--- lockfile Vitest package entries ---'
rg -n -A4 -B2 \
  '(^|/)vitest@|vitest:' \
  pnpm-lock.yaml 2>/dev/null | head -120 || true

Repository: team-reflect/reflect-open

Length of output: 17965


🌐 Web query:

Vitest official documentation projects defineProject root config fileParallelism project config inheritance

💡 Result:

Vitest projects (formerly known as workspaces) allow you to run multiple configurations within a single Vitest process [1]. DefineProject The defineProject method is recommended for use within project configuration files (e.g., vitest.config.ts for a specific sub-project) to provide better type safety compared to defineConfig [2][1]. Root Config File Projects can be defined directly in your root configuration file using the test.projects array [2][1]. This array can contain objects (inline configuration), strings (file paths or glob patterns to other config files), or directories [2][3]. The root configuration file itself does not act as a project unless explicitly included in the projects array; it serves primarily to manage global options like reporters and coverage [1][4]. Parallelism Vitest supports file-level parallelism by default, running test files across multiple workers [5]. You can control this behavior per project by setting the fileParallelism property within a project's configuration [6]. For example, you can define a project with fileParallelism: false to force sequential execution for specific test suites, while other projects run in parallel [6]. Project Config Inheritance Inheritance behavior depends on how the project is defined: 1. Inline Projects: As of recent versions (starting with Vitest 5.0), inline projects inherit all options from the root-level configuration by default via the extends: true option [1][7]. You can disable this inheritance by setting extends: false [1][7]. 2. Config Files or Directories: Projects referenced as external config files or directories do not inherit options from the root configuration [1]. To share configuration, you can create a common shared config file and merge it explicitly using the mergeConfig utility [2][1]. 3. Special Cases: Certain options are never inherited (e.g., name and projects) [1][7]. globalSetup is not inherited from the root config because it is intended to run once per test process, but it is inherited when extending a non-root config file [1][7]. Tags replace the inherited array rather than merging with it [1]. [2][1][7][5][6]

Citations:


Preserve serial file execution in both core projects.

The root fileParallelism: false does not apply to the external core project configs. Add it to packages/core/vitest.browser.config.ts and packages/core/vitest.node.config.ts, or prove that all core test files are safe to run in parallel.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/vitest.browser.config.ts` around lines 10 - 17, Add
fileParallelism: false to the top-level Vitest configuration in both the browser
and node core project configs, alongside the existing sequence/retry settings,
so core test files continue executing serially. Do not alter the existing
browser or test execution settings.

@ocavue
ocavue merged commit d6446a5 into master Jul 31, 2026
15 checks passed
@ocavue
ocavue deleted the remove-jsdom branch July 31, 2026 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant