Home

Awesome

borp

Borp is a typescript-aware test runner for node:test. It also support code coverage via c8.

Borp is self-hosted, i.e. Borp runs its own tests.

Install

npm i borp --save-dev

Usage

borp --coverage

# with check coverage active
borp --coverage --check-coverage --lines 95

# with a node_modules located reporter
borp --reporter foo

# with a node_modules located reporter writing to stderr
borp --reporter foo:stderr

# with a local custom reporter
borp --reporter ./lib/some-reporter.mjs

Borp will automatically run all tests files matching *.test.{js|ts}.

Example project setup

.
├── src
│   ├── lib
│   │   └── math.ts
│   └── test
│       └── math.test.ts
└── tsconfig.json

As an example, consider having a src/lib/math.ts file

export function math (x: number, y: number): number {
  return x + y
}

and a src/test/math.test.ts file:

import { test } from 'node:test'
import { math } from '../lib/math.js'
import { strictEqual } from 'node:assert'

test('math', () => {
  strictEqual(math(1, 2), 3)
})

and the following tsconfig.json:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "outDir": "dist",
    "sourceMap": true,
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "esModuleInterop": true,
    "strict": true,
    "resolveJsonModule": true,
    "removeComments": true,
    "newLine": "lf",
    "noUnusedLocals": true,
    "noFallthroughCasesInSwitch": true,
    "isolatedModules": true,
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true,
    "lib": [
      "ESNext"
    ],
    "incremental": true
  }
}

Note the use of incremental: true, which speed up compilation massively.

Options

Check coverage options

Reporters

Here are the available reporters:

License

MIT