MCPcopy Index your code
hub / github.com/BRIKEV/twd

github.com/BRIKEV/twd @v1.8.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.8.2 ↗ · + Follow
294 symbols 917 edges 175 files 3 documented · 1%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TWD (Test While Developing)

CI npm version license Maintainability Code Coverage

TWD running with an AI agent: tests written and executed in a real browser sidebar

Frontend tests that run in your real browser. Same DOM, same routes, same state as your dev server. For React, Vue, Angular, and Solid.

The problem

Testing gets pushed to next week, and next week never comes. When it does happen, tests usually run in a different environment from where you're building, so testing feels like overhead the moment you finish a feature.

The tooling pushes you the same way. You end up writing more code for the tests than for the feature itself, between setup, mocks, and helpers. Adding tests starts to feel like shipping a second app on top of the one you already finished.

As AI writes more of your code, the gap widens. Agents generate test files that look correct but never actually execute in a real browser. The mocks those tests rely on quietly drift from the real API over time. Fields get renamed, mocks stay frozen, tests pass, production breaks.

The solution

TWD puts tests inside your dev server. A sidebar appears in your real browser, runs tests against the same DOM your users see, and updates as you code. When you're ready, plug in an AI agent that writes tests, runs them via a WebSocket bridge, and iterates until they pass. When you ship, validate every mock against your OpenAPI spec to catch drift before a user does.

Test what you own. Mock what you don't.

Full pitch and docs at twd.dev.

Quick start

npm install --save-dev twd-js

Add the Vite plugin (auto-loads the sidebar and discovers your test files):

// vite.config.ts
import { defineConfig } from 'vite'
import { twd } from 'twd-js/vite-plugin'

export default defineConfig({
  plugins: [twd({ open: true })],
})

Write a test next to your code:

// src/App.twd.test.ts
import { twd, screenDom } from 'twd-js'
import { describe, it } from 'twd-js/runner'

describe('App', () => {
  it('shows the heading', async () => {
    await twd.visit('/')
    const heading = await screenDom.findByRole('heading', { level: 1 })
    twd.should(heading, 'be.visible')
  })
})

Run npm run dev and open the app. The TWD sidebar appears in your browser; click play to run the test.

Full setup guide · Framework integration (Angular, non-Vite, Astro, React Router)

The TWD ecosystem

One package today. The rest when you need it.

Tool What it does
twd-js The core sidebar. Frontend tests that run in your real browser.
twd-relay Token-efficient browser testing for AI agents. Structured pass/fail over WebSocket. No Playwright, no screenshots.
twd-cli Headless CI runs with coverage and OpenAPI contract validation.

Examples & showcase

All examples and community content

Documentation

Contributing

Open issues or pull requests on GitHub. If you're starting out in tech and looking for a beginner-friendly first PR, see the open issues. Reach out and the maintainer will help with setup and walk you through it.

Contributors ✨

Kevin Julián Martínez Escobar Kevin Julián Martínez Escobar 💻 Javier Rodriguez Javier Rodriguez 📖 Guillermo Ruiz Arranz Guillermo Ruiz Arranz 💻 Roberto Gomez Fabrega Roberto Gomez Fabrega 📖

This project follows the all-contributors specification. Contributions of any kind are welcome.

License

MIT

Extension points exported contracts — how you extend this code

Window (Interface)
(no doc)
src/global.d.ts
TestModule (Interface)
(no doc)
src/bundled.tsx
TWDElemAPI (Interface)
(no doc)
src/twd-types.ts
TestResult (Interface)
(no doc)
src/runner-ci.ts
TWDAPI (Interface)
(no doc)
src/twd.ts
Handler (Interface)
(no doc)
src/runner.ts
Options (Interface)
(no doc)
src/initializers/initSidebar.tsx
TwdHmrOptions (Interface)
(no doc)
src/plugin/twdHmr.ts

Core symbols most depended-on inside this repo

runAssertion
called by 70
src/asserts/index.ts
findRule
called by 67
src/cli/utils/findRule.js
beforeEach
called by 50
src/runner.ts
domMessage
called by 28
src/proxies/domMessage.ts
mockRequest
called by 27
src/commands/mockBridge.ts
log
called by 23
src/utils/log.ts
waitFor
called by 23
src/utils/waitFor.ts
initRequestMocking
called by 19
src/commands/mockBridge.ts

Shape

Function 228
Interface 45
Method 14
Class 6
Enum 1

Languages

TypeScript100%

Modules by API surface

src/runner.ts25 symbols
src/commands/viewport.ts16 symbols
src/commands/mockBridge.ts12 symbols
src/ui/TWDSidebar.tsx10 symbols
src/proxies/screenDom.ts10 symbols
examples/tutorial-example/src/components/ui/dialog.tsx10 symbols
src/ui/utils/formatLogs.ts9 symbols
examples/vue-twd-example/public/mock-sw.js9 symbols
examples/twd-test-app/public/mock-sw.js9 symbols
examples/tutorial-example/public/mock-sw.js9 symbols
src/tests/commands/mockBridge/initMocking.spec.ts7 symbols
examples/tutorial-example/src/components/ui/card.tsx7 symbols

For agents

$ claude mcp add twd \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact