bugsbasters
v0.3.0
Published
Fast, simple testing library with Rust-powered performance
Maintainers
Readme
BugsBasters
A fast, simple testing library with Rust-powered performance and a clean JavaScript/TypeScript API.
Features
- Fast - Rust core with parallel test execution via Rayon
- Simple API - Clean, intuitive test syntax inspired by Jest
- Beautiful Reports - Terminal colors, HTML reports, JUnit XML
- Powerful Mocking - Simple
mock()andspy()functions - Snapshot Testing - Capture and compare output snapshots
- Watch Mode - Auto-run tests on file changes
- Code Coverage - Built-in V8 coverage support
- CI Ready - Auto-detects GitHub Actions, GitLab CI, etc.
Installation
npm install bugsbastersQuick Start
import { test, expect, describe } from 'bugsbasters';
describe('Math', () => {
test('adds numbers correctly', () => {
expect(1 + 1).toBe(2);
});
test('multiplies numbers', () => {
expect(3 * 4).toEqual(12);
});
});Run tests:
npx bugsbasters runAPI
Test Functions
test('name', () => { /* test code */ });
test.skip('skipped test', () => { });
test.only('only this test runs', () => { });
test.todo('not implemented yet');
// Parameterized tests
test.each([[1, 1, 2], [2, 3, 5]])('adds %d + %d = %d', (a, b, sum) => {
expect(a + b).toBe(sum);
});
// Test suites
describe('Suite', () => {
beforeEach(() => { /* setup */ });
afterEach(() => { /* cleanup */ });
test('...', () => { });
});Assertions
expect(value).toBe(4); // strict equality
expect(obj).toEqual({ a: 1 }); // deep equality
expect(arr).toContain(2); // contains
expect(arr).toHaveLength(3); // length
expect(fn).toThrow('error'); // throws
expect(value).toBeTruthy(); // truthy
expect(value).toBeFalsy(); // falsy
expect(value).toBeNull(); // null
expect(value).toBeDefined(); // defined
expect(value).toBeGreaterThan(5); // comparison
expect(value).toBeLessThan(10); // comparison
expect(str).toMatch(/pattern/); // regex match
expect(obj).toHaveProperty('key', value); // property
expect(obj).toMatchObject({ a: 1 }); // partial match
expect(promise).toResolve(); // async
expect(promise).toReject(); // async
// Negation
expect(value).not.toBe(4);Mocking
import { mock, spy } from 'bugsbasters';
// Create mock function
const fn = mock();
fn(1, 2);
expect(fn).toHaveBeenCalled();
expect(fn).toHaveBeenCalledWith(1, 2);
expect(fn).toHaveBeenCalledTimes(1);
// Return values
const fn = mock().returns(42);
const fn = mock().resolves(data);
const fn = mock().rejects(error);
const fn = mock().throws(error);
// Spy on existing method
const spy = spy(object, 'method').returns(10);
spy.restore(); // restore originalSnapshot Testing
// Capture output as snapshot
expect(data).toMatchSnapshot();
// First run creates the snapshot file
// Subsequent runs compare against itUpdate snapshots:
npx bugsbasters run --update-snapshotsWatch Mode
Automatically re-run tests when files change:
npx bugsbasters watchKeyboard shortcuts in watch mode:
Enter- Re-run testsu- Update snapshotsa- Run all testsq- Quit
Code Coverage
Collect coverage data:
npx bugsbasters run --coverageCLI Options
bugsbasters run [pattern]
Options:
-p, --parallel Run tests in parallel (default: true)
--no-parallel Run tests sequentially
-r, --reporter <type> Reporter: terminal, html, json, junit
-o, --output <file> Output file for report
--root <dir> Root directory for test discovery
-t, --timeout <ms> Test timeout (default: 5000)
-u, --update-snapshots Update snapshot files
--coverage Collect code coverage
bugsbasters watch [pattern]
Options:
--root <dir> Root directory
-t, --timeout <ms> Test timeout
--no-clear Don't clear screen between runsReporters
Terminal (default)
BugsBasters v0.1.0
✓ adds numbers correctly 2ms
✓ subtracts correctly 1ms
✗ divides by zero 3ms
Expected: Error("Cannot divide by zero")
Received: 0
Tests: 2 passed, 1 failed (3)
Time: 127msHTML Report
npx bugsbasters run --reporter htmlGenerates a clean, single-file HTML report.
JUnit XML
npx bugsbasters run --reporter junit -o results.xmlBuilding from Source
Prerequisites
- Node.js 18+
- Rust 1.70+
- npm or pnpm
Build
# Install dependencies
npm install
# Build TypeScript
npm run build
# Build native module (requires Rust)
npm run build:nativeArchitecture
bugsbasters/
├── crates/
│ ├── bugsbasters-core/ # Rust: test engine, reports, CI
│ └── bugsbasters-napi/ # Rust: Node.js bindings (NAPI-RS)
├── packages/
│ └── bugsbasters/ # JS/TS: API wrapper + CLI
└── templates/ # HTML report templatesLicense
MIT
