
testing
Run and troubleshoot tests for DBHub, including unit tests, integration tests with Testcontainers, and database-specific tests. Use when asked to run tests, fix test failures, debug integration tests, troubleshoot Docker/database container issues, or add new tests. Also use when verifying code changes work correctly or when CI test failures need investigation.
- Installs
- 82
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/bytebase/dbhub --skill testing- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads testing automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Testing Skill
This skill helps you run, write, and troubleshoot tests in the DBHub project.
Test Commands
pnpm test # Run all tests (unit + integration)
pnpm test:unit # Unit tests only (no Docker needed)
pnpm test:watch # Interactive watch mode
pnpm test:integration # Integration tests only (requires Docker)
Run a specific test file:
pnpm test src/connectors/__tests__/postgres.integration.test.ts
pnpm test src/utils/__tests__/allowed-keywords.test.ts
Run tests matching a name pattern:
pnpm test -- --testNamePattern="PostgreSQL"
Verbose output for debugging:
pnpm test:integration --reporter=verbose
Test Architecture
Vitest is configured with two projects in vitest.config.ts:
- unit: All
*.test.tsfiles excluding*integration*in the filename - integration: Only
*integration*.test.tsfiles
This means the naming convention matters — integration tests MUST have integration in their filename to be correctly categorized.
Test File Locations
Unit tests (~20 files, no Docker needed):
src/utils/__tests__/— Utility function tests (SQL parsing, DSN obfuscation, SSH config, allowed keywords, identifier quoting, parameter mapping, row limiting, safe URL, config watcher, AWS RDS signer)src/tools/__tests__/— Tool handler tests (execute-sql, search-objects, custom-tool-handler)src/config/__tests__/— Configuration tests (env parsing, TOML loading)src/connectors/__tests__/— Connector unit tests (dsn-parser, manager)src/requests/__tests__/— Request store tests
Integration tests (~11 files, Docker required):
src/connectors/__tests__/postgres.integration.test.tssrc/connectors/__tests__/mysql.integration.test.tssrc/connectors/__tests__/mariadb.integration.test.tssrc/connectors/__tests__/sqlserver.integration.test.tssrc/connectors/__tests__/oracle.integration.test.tssrc/connectors/__tests__/sqlite.integration.test.tssrc/connectors/__tests__/postgres-ssh.integration.test.tssrc/connectors/__tests__/multi-sqlite-sources.integration.test.tssrc/__tests__/json-rpc-integration.test.tssrc/api/__tests__/sources.integration.test.tssrc/api/__tests__/requests.integration.test.tssrc/config/__tests__/ssh-config-integration.test.ts
IntegrationTestBase
Database connector integration tests extend IntegrationTestBase<TContainer> from src/connectors/__tests__/shared/integration-test-base.ts. This abstract class provides:
- Lifecycle: Container start in
beforeAll(120s timeout) → connect → setup test data → run tests → cleanup inafterAll - Shared test suites:
createConnectionTests(),createSchemaTests(),createTableTests(),createSQLExecutionTests(),createStoredProcedureTests(),createCommentTests(),createErrorHandlingTests() - Standard test data:
userstable (id, name, email, age) +orderstable (id, user_id, amount) +test_schema.products
To add a new database connector test, extend this class and implement:
createContainer()— Start the Testcontainers instancecreateConnector()— Create the database connectorsetupTestData(connector)— Populate test tables
Test Fixtures
Located in src/__fixtures__/:
helpers.ts— Utilities:fixtureTomlPath(),loadFixtureConfig(),setupManagerWithFixture()toml/multi-sqlite.toml— Three in-memory SQLite databases (database_a, database_b, database_c)toml/readonly-maxrows.toml— Sources with readonly/max_rows tool configurations
Usage:
import { setupManagerWithFixture, FIXTURES } from '../../__fixtures__/helpers.js';
const manager = await setupManagerWithFixture(FIXTURES.MULTI_SQLITE);
// ... test ...
await manager.disconnect();
Mocking Patterns
Unit tests use vitest mocking:
vi.mock('../../connectors/manager.js'); // Mock ConnectorManager
vi.mocked(ConnectorManager.getCurrentConnector).mockReturnValue(mockConnector);
SSH tunnel tests mock SSHTunnel.prototype.establish to avoid real SSH connections while testing config passing.
Integration Testing
Integration tests use Testcontainers to run real database instances in Docker.
Prerequisites
Before running integration tests:
- Docker is installed and running:
docker ps - Sufficient Docker memory (4GB+ recommended, especially for SQL Server)
- Network access to pull Docker images
Database Images
| Database | Image | Notes |
|---|---|---|
| PostgreSQL | postgres:15-alpine | Fast startup |
| MySQL | @testcontainers/mysql | Supports IAM auth testing |
| MariaDB | @testcontainers/mariadb | Supports IAM auth testing |
| SQL Server | @testcontainers/mssqlserver | Slow startup (3-5 min), needs 4GB+ RAM |
| Oracle | @testcontainers/oraclefree (gvenzl/oracle-free:23-slim-faststart) | ~1.2GB pull, 1-2 min startup, needs 2GB+ RAM |
| SQLite | No container needed | In-memory or file-based |
Troubleshooting
Container Startup Failures
docker ps # Verify Docker is running
docker system df # Check disk space
docker pull postgres:15-alpine # Manually pull images
SQL Server Timeouts
SQL Server containers are the slowest to start (3-5 minutes). Run them separately and ensure Docker has 4GB+ memory:
pnpm test src/connectors/__tests__/sqlserver.integration.test.ts
Test Isolation Issues
Each integration test manages its own container lifecycle. If containers leak, clean up:
docker ps -a | grep testcontainers # Find leaked containers
docker container prune # Clean up stopped containers
"Hook timed out in 10000ms" in afterAll
All tests pass but the suite is marked failed at its afterAll (seen on MariaDB and
postgres-ssh in CI). Teardown is container.stop(), which runs docker stop -t 0
followed by docker rm -v (removing the data volume). On a shared Docker daemon that
is simultaneously pulling/extracting the Oracle or SQL Server image, that removal can
exceed Vitest's 10s default hook timeout. The integration project sets
hookTimeout: 60_000 in vitest.config.ts for this reason — do not pass a shorter
timeout to afterAll, and if you add a suite with its own teardown, let it use the
project default rather than the Vitest default.
CI Failures
The CI workflow (.github/workflows/run-tests.yml) runs unit and integration tests as separate parallel jobs on PR events. Unit tests don't need Docker; integration tests verify Docker availability first. Check the specific job that failed.
Adding New Tests
Unit test: Create src/{module}/__tests__/{name}.test.ts — will auto-run with pnpm test:unit.
Integration test: Create src/{module}/__tests__/{name}.integration.test.ts — the integration in the filename is what routes it to pnpm test:integration.
New connector test: Extend IntegrationTestBase, implement the three abstract methods, and call the shared test suite methods.
FAQ
What does the testing skill do?
Run and troubleshoot tests for DBHub, including unit tests, integration tests with Testcontainers, and database-specific tests. Use when asked to run tests, fix test failures, debug integration tests, troubleshoot Docker/database container issues, or add new tests. Also use when verifying code changes work correctly or when CI test failures need investigation.
How do I install testing?
Run npx skills add https://github.com/bytebase/dbhub --skill testing in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/testing/ (personal) or .claude/skills/testing/ (project).
Which AI agents can use testing?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is testing safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains testing?
It is published by bytebase in bytebase/dbhub. It has 82 recorded installs.
More from bytebase/dbhub
dbhub
bytebase/dbhub
Guide for querying databases through DBHub MCP server. Use this skill whenever you need to explore database schemas, inspect tables, or run SQL queries via DBHub's MCP tools (searchobjects, executesql, and the opt-in explainsql and healthcheck). Activates on any database query task, schema exploration, data retrieval, or SQL execution through MCP — even if the user just says "check the database" or "find me some data." This skill ensures you follow the correct explore-first workflow instead of guessing table structures.
fix-bug
bytebase/dbhub
Open the skill to read its SKILL.md instructions.
Popular testing & qa skills
tdd
mattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
grilling
mattpocock/skills
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
migrate-to-shoehorn
mattpocock/skills
Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.
run-train
lllllllama/rigorpilot-skills
Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.
test-driven-development
obra/superpowers
Use when implementing any feature or bugfix, before writing implementation code
finishing-a-development-branch
obra/superpowers
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work