[PR #90] [MERGED] refactor: colocate tests with implementations and add mode-based test runner #110

Closed
opened 2026-02-16 06:17:11 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/90
Author: @christian-bromann
Created: 1/3/2026
Status: Merged
Merged: 1/8/2026
Merged by: @christian-bromann

Base: mainHead: cb/test-refactor


📝 Commits (10+)

  • 0c7428e feat: catch up with Python
  • ada21f0 add example
  • 0f4b979 feat: add SDK Skills + Memory System
  • eb346c0 add example
  • 146f6be refactor: colocate tests with implementations and add mode-based test runner
  • 0c608a2 run integration tests in CI
  • bc3ad8c fix prettier issues in Windows
  • f61ac47 fix globbing
  • d8c8aa3 fix linting
  • 990abb8 add dependabot file

📊 Changes

31 files changed (+515 additions, -398 deletions)

View changed files

.gitattributes (+3 -0)
.github/dependabot.yml (+35 -0)
📝 .github/workflows/ci.yml (+39 -33)
📝 .github/workflows/pr_lint.yml (+1 -1)
📝 .github/workflows/release.yml (+4 -7)
.github/workflows/unit-tests.yml (+0 -45)
📝 .prettierrc (+3 -1)
📝 eslint.config.js (+1 -1)
📝 examples/skills/skill-creator/scripts/init_skill.ts (+1 -0)
📝 examples/skills/skill-creator/scripts/quick_validate.ts (+1 -0)
📝 package.json (+5 -3)
📝 src/agent.int.test.ts (+46 -46)
📝 src/backends/composite.test.ts (+74 -50)
📝 src/backends/filesystem.test.ts (+1 -1)
📝 src/backends/protocol.test.ts (+1 -2)
📝 src/backends/sandbox.test.ts (+102 -51)
📝 src/backends/state.test.ts (+3 -5)
📝 src/backends/store.test.ts (+16 -13)
📝 src/config.test.ts (+1 -5)
📝 src/middleware/agent-memory.test.ts (+43 -26)

...and 11 more files

📄 Description

This PR refactors the test infrastructure to colocate test files with their implementation files, following the pattern used in langchainjs.

Changes

  • Unit tests (*.test.ts) now live next to their implementation files in src/
  • Integration tests (*.int.test.ts) also live next to their implementations
  • Vitest configuration updated with mode-based test selection:
    • pnpm test — runs linting + unit tests (default)
    • pnpm test:unit — runs unit tests only
    • pnpm test:int — runs integration tests with --mode int
  • Test utilities moved to src/testing/utils.ts
  • Removed legacy tests/ directory

Motivation

Better Test Coverage Visibility

Colocating test files with their implementations provides immediate visibility into test coverage at the file level. When browsing the codebase, you can instantly see which files have accompanying unit tests:

src/backends/
├── composite.ts
├── composite.test.ts     ✅ tested
├── filesystem.ts
├── filesystem.test.ts    ✅ tested
├── protocol.ts
├── protocol.test.ts      ✅ tested
├── sandbox.ts
├── sandbox.test.ts       ✅ tested
├── state.ts
├── state.test.ts         ✅ tested
├── store.ts
├── store.test.ts         ✅ tested
├── utils.ts              ⚠️ missing test!
└── index.ts

With this structure, missing tests become immediately obvious during code review and everyday development. There's no need to cross-reference between two separate directory trees (src/ and tests/) to verify coverage. Also with previous setup all Eslint checks were not set up to run on tests/ causing a lot of lint issues trickle down into main. This refactor will prevent this in the future.

Improved Developer Experience

  1. Faster navigation — Tests are one click away from implementation in any editor
  2. Easier refactoring — When moving/renaming a file, the test moves with it
  3. Clear ownership — Each module is responsible for its own tests
  4. Reduced cognitive load — No mental mapping between parallel directory structures

Separation of Unit and Integration Tests

The new --mode int flag allows running integration tests separately, which:

  • Keeps the default pnpm test fast (unit tests only)
  • Allows CI to run integration tests in a separate job with proper environment setup
  • Makes it clear which tests require external resources (API keys, etc.)

Test Plan

# Run unit tests (fast, no external dependencies)
pnpm test:unit

# Run integration tests (requires API keys)
pnpm test:int

# Run linting + unit tests (CI default)
pnpm test

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/90 **Author:** [@christian-bromann](https://github.com/christian-bromann) **Created:** 1/3/2026 **Status:** ✅ Merged **Merged:** 1/8/2026 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `main` ← **Head:** `cb/test-refactor` --- ### 📝 Commits (10+) - [`0c7428e`](https://github.com/langchain-ai/deepagentsjs/commit/0c7428eb0eac5ed5636ff7555ced91e0954038b5) feat: catch up with Python - [`ada21f0`](https://github.com/langchain-ai/deepagentsjs/commit/ada21f04a6304ed7a392d03da018209afc631baf) add example - [`0f4b979`](https://github.com/langchain-ai/deepagentsjs/commit/0f4b9792cbc0b8337cc38f8215cfc591da76d412) feat: add SDK Skills + Memory System - [`eb346c0`](https://github.com/langchain-ai/deepagentsjs/commit/eb346c04a5bdcaf0ab8561bafaae23fd0c6fe016) add example - [`146f6be`](https://github.com/langchain-ai/deepagentsjs/commit/146f6becb02fd233d942de8ee76d91384dea4377) refactor: colocate tests with implementations and add mode-based test runner - [`0c608a2`](https://github.com/langchain-ai/deepagentsjs/commit/0c608a2b627e5f8785cedf8bf387c9ee1c822cd8) run integration tests in CI - [`bc3ad8c`](https://github.com/langchain-ai/deepagentsjs/commit/bc3ad8c0a7d34edf4c18d4bf4f356d2a47013a0f) fix prettier issues in Windows - [`f61ac47`](https://github.com/langchain-ai/deepagentsjs/commit/f61ac47cd4f4501af6f179c0119a7e25c3d1e2c6) fix globbing - [`d8c8aa3`](https://github.com/langchain-ai/deepagentsjs/commit/d8c8aa3b93aff2a9b94777671e1dd085471253e5) fix linting - [`990abb8`](https://github.com/langchain-ai/deepagentsjs/commit/990abb83bcf6ad15ac2f24ba765a55487e6c1e7e) add dependabot file ### 📊 Changes **31 files changed** (+515 additions, -398 deletions) <details> <summary>View changed files</summary> ➕ `.gitattributes` (+3 -0) ➕ `.github/dependabot.yml` (+35 -0) 📝 `.github/workflows/ci.yml` (+39 -33) 📝 `.github/workflows/pr_lint.yml` (+1 -1) 📝 `.github/workflows/release.yml` (+4 -7) ➖ `.github/workflows/unit-tests.yml` (+0 -45) 📝 `.prettierrc` (+3 -1) 📝 `eslint.config.js` (+1 -1) 📝 `examples/skills/skill-creator/scripts/init_skill.ts` (+1 -0) 📝 `examples/skills/skill-creator/scripts/quick_validate.ts` (+1 -0) 📝 `package.json` (+5 -3) 📝 `src/agent.int.test.ts` (+46 -46) 📝 `src/backends/composite.test.ts` (+74 -50) 📝 `src/backends/filesystem.test.ts` (+1 -1) 📝 `src/backends/protocol.test.ts` (+1 -2) 📝 `src/backends/sandbox.test.ts` (+102 -51) 📝 `src/backends/state.test.ts` (+3 -5) 📝 `src/backends/store.test.ts` (+16 -13) 📝 `src/config.test.ts` (+1 -5) 📝 `src/middleware/agent-memory.test.ts` (+43 -26) _...and 11 more files_ </details> ### 📄 Description This PR refactors the test infrastructure to colocate test files with their implementation files, following the pattern used in `langchainjs`. ## Changes - **Unit tests** (`*.test.ts`) now live next to their implementation files in `src/` - **Integration tests** (`*.int.test.ts`) also live next to their implementations - **Vitest configuration** updated with mode-based test selection: - `pnpm test` — runs linting + unit tests (default) - `pnpm test:unit` — runs unit tests only - `pnpm test:int` — runs integration tests with `--mode int` - Test utilities moved to `src/testing/utils.ts` - Removed legacy `tests/` directory ## Motivation ### Better Test Coverage Visibility Colocating test files with their implementations provides immediate visibility into test coverage at the file level. When browsing the codebase, you can instantly see which files have accompanying unit tests: ``` src/backends/ ├── composite.ts ├── composite.test.ts ✅ tested ├── filesystem.ts ├── filesystem.test.ts ✅ tested ├── protocol.ts ├── protocol.test.ts ✅ tested ├── sandbox.ts ├── sandbox.test.ts ✅ tested ├── state.ts ├── state.test.ts ✅ tested ├── store.ts ├── store.test.ts ✅ tested ├── utils.ts ⚠️ missing test! └── index.ts ``` With this structure, missing tests become immediately obvious during code review and everyday development. There's no need to cross-reference between two separate directory trees (`src/` and `tests/`) to verify coverage. Also with previous setup all Eslint checks were not set up to run on `tests/` causing a lot of lint issues trickle down into `main`. This refactor will prevent this in the future. ### Improved Developer Experience 1. **Faster navigation** — Tests are one click away from implementation in any editor 2. **Easier refactoring** — When moving/renaming a file, the test moves with it 3. **Clear ownership** — Each module is responsible for its own tests 4. **Reduced cognitive load** — No mental mapping between parallel directory structures ### Separation of Unit and Integration Tests The new `--mode int` flag allows running integration tests separately, which: - Keeps the default `pnpm test` fast (unit tests only) - Allows CI to run integration tests in a separate job with proper environment setup - Makes it clear which tests require external resources (API keys, etc.) ## Test Plan ```bash # Run unit tests (fast, no external dependencies) pnpm test:unit # Run integration tests (requires API keys) pnpm test:int # Run linting + unit tests (CI default) pnpm test ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 06:17:11 -05:00
yindo closed this issue 2026-02-16 06:17:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#110