Skip to content

Conversation

@miguelg719
Copy link
Collaborator

@miguelg719 miguelg719 commented Jan 28, 2026

why

Currently we have two test directories in core, consolidating under core/test

what changed

Move Vitest unit tests from packages/core/tests/ to packages/core/lib/v3/tests/unit/ to consolidate all tests under a single tests directory.

Changes:

Move all .test.ts files from tests/ to lib/v3/tests/unit/
Move tests/public-api/ to lib/v3/tests/unit/public-api/
Move tests/helpers/ to lib/v3/tests/unit/helpers/
Update vitest.config.ts to point to new location
Update tsconfig.json to exclude unit tests from typecheck
Fix import paths in moved test files
The lib/v3/tests/ directory now contains:

*.spec.ts files: Playwright integration tests (existing)
unit/: Vitest unit tests (moved)

test plan


Summary by cubic

Consolidated all core tests into packages/core/tests with unit tests in tests/unit and Playwright specs in tests/integration. This simplifies the layout and meets Linear STG-1021’s “single tests directory” requirement.

  • Refactors
    • Moved Playwright *.spec.ts to tests/integration and updated package.json scripts to use the new config paths.
    • Moved Vitest unit tests to tests/unit and limited vitest.config include to tests/unit/**/*.test.ts.
    • Fixed import paths in all moved tests to reference ../../lib/v3.
    • Updated tsconfig to exclude tests from typecheck.

Written for commit 5162c7c. Summary will update on new commits. Review in cubic

Move Vitest unit tests from packages/core/tests/ to
packages/core/lib/v3/tests/unit/ to consolidate all tests under a single
tests directory.

Changes:
- Move all .test.ts files from tests/ to lib/v3/tests/unit/
- Move tests/public-api/ to lib/v3/tests/unit/public-api/
- Move tests/helpers/ to lib/v3/tests/unit/helpers/
- Update vitest.config.ts to point to new location
- Update tsconfig.json to exclude unit tests from typecheck
- Fix import paths in moved test files

The lib/v3/tests/ directory now contains:
- *.spec.ts files: Playwright integration tests (existing)
- unit/: Vitest unit tests (moved)

# why

# what changed

# test plan

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Consolidated all core tests under packages/core/tests, with unit tests
in tests/unit and Playwright *.spec.ts in tests/integration, meeting
Linear STG-1021’s “single tests directory” requirement.

- **Refactors**
- Moved lib/v3/tests/* and test/* into tests/integration and tests/unit.
  - Updated vitest.config include to tests/unit/**/*.test.ts.
- Updated package.json scripts to use tests/integration Playwright
configs.
  - Fixed import paths in moved test files.

<sup>Written for commit 4a1e13c.
Summary will update on new commits. <a
href="https://cubic.dev/pr/browserbase/stagehand/pull/1621">Review in
cubic</a></sup>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Chromie Bot <chromie@browserbase.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: 5162c7c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@miguelg719 miguelg719 marked this pull request as ready for review January 28, 2026 00:36
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 77 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Architecture diagram
sequenceDiagram
    participant Dev as CI / Developer
    participant NPM as package.json Scripts
    participant Config as Test Configs
    participant Runner as Test Runner (Vitest/Playwright)
    participant Tests as Test Files
    participant Core as Core Library (lib/v3)

    Note over Dev,Core: PR Refactor: Consolidation of Test Directories & Import Path Updates

    alt Unit Tests (Vitest)
        Dev->>NPM: pnpm test:vitest
        NPM->>Config: Load vitest.config.ts
        Config->>Runner: CHANGED: include "tests/unit/**/*.test.ts"
        Runner->>Tests: Execute Unit Tests
        Tests->>Core: CHANGED: Import V3 from "../../lib/v3"
        Core-->>Tests: Return Modules
        Tests-->>Runner: Pass/Fail
    else Integration Tests (Playwright)
        Dev->>NPM: pnpm test / e2e
        NPM->>Config: CHANGED: Load config from "tests/integration/..."
        Note right of NPM: Was: lib/v3/tests/...
        Config->>Runner: Configure Environment
        Runner->>Tests: Execute *.spec.ts
        Tests->>Core: CHANGED: Import V3 from "../../lib/v3"
        Note right of Tests: Adjusted relative depth (was ../v3)
        Core-->>Tests: Return V3 Instance
        Tests-->>Runner: Pass/Fail
    end

    opt Typecheck
        Dev->>NPM: pnpm typecheck
        NPM->>Config: Load tsconfig.json
        Config->>Core: CHANGED: Exclude "test/**/*" from build
    end
Loading

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 28, 2026

Greptile Overview

Greptile Summary

This PR consolidates all test files under a single packages/core/tests/ directory, separating Playwright integration tests (tests/integration/) from Vitest unit tests (tests/unit/). This resolves the previous split between packages/core/tests/ and packages/core/lib/v3/tests/.

Key Changes:

  • Moved 26 unit test files from tests/ to tests/unit/
  • Moved 49 integration test files from lib/v3/tests/ to tests/integration/
  • Updated all import paths in test files to use ../../lib/v3/
  • Updated vitest.config.ts to only include tests/unit/**/*.test.ts
  • Updated package.json test scripts to point to new Playwright config locations
  • Excluded tests/**/* from TypeScript compilation in tsconfig.json

The reorganization is complete and consistent across all 77 files. All configuration files have been updated appropriately to reference the new test locations.

Confidence Score: 5/5

  • This PR is safe to merge with no issues - it's a pure refactoring that moves test files without changing functionality
  • This is a straightforward directory reorganization with no logical changes to any code. All import paths were correctly updated, configuration files properly reference new locations, and the move achieves the stated goal of consolidating tests under a single directory
  • No files require special attention

Important Files Changed

Filename Overview
packages/core/tsconfig.json Moved tests directory from include to exclude list to prevent typecheck on tests
packages/core/vitest.config.ts Updated include path to point to tests/unit/**/*.test.ts for Vitest unit tests
packages/core/package.json Updated Playwright config paths in test scripts to point to tests/integration/
.changeset/giant-sloths-invent.md Added changeset entry documenting the test directory consolidation

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant OldStructure as Old Structure
    participant NewStructure as New Structure
    participant Config as Config Files
    
    Note over OldStructure: packages/core/tests/*.test.ts<br/>packages/core/lib/v3/tests/*.spec.ts
    
    Dev->>OldStructure: Move unit tests
    OldStructure->>NewStructure: tests/*.test.ts → tests/unit/*.test.ts
    
    Dev->>OldStructure: Move integration tests
    OldStructure->>NewStructure: lib/v3/tests/*.spec.ts → tests/integration/*.spec.ts
    
    Dev->>NewStructure: Update imports in test files
    Note over NewStructure: All imports now use ../../lib/v3/
    
    Dev->>Config: Update vitest.config.ts
    Note over Config: include: tests/unit/**/*.test.ts
    
    Dev->>Config: Update package.json
    Note over Config: Playwright configs → tests/integration/
    
    Dev->>Config: Update tsconfig.json
    Note over Config: Exclude tests/**/* from typecheck
    
    Note over NewStructure: packages/core/tests/<br/>├── integration/*.spec.ts<br/>└── unit/*.test.ts
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

miguelg719 and others added 2 commits January 27, 2026 16:40
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@miguelg719
Copy link
Collaborator Author

@greptileai

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

3 participants