Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

borp

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

borp

node:test wrapper with TypeScript support

  • 0.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.3K
increased by34.62%
Maintainers
1
Weekly downloads
 
Created
Source

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

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

Example project setup

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

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

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

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

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

test('add', () => {
  strictEqual(add(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

  • --concurrency or -c, to set the number of concurrent tests. Defaults to the number of available CPUs minus one.
  • --coverage or -C, enables code coverage
  • --only or -o, only run node:test with the only option set
  • --watch or -w, re-run tests on changes
  • --timeout or -t, timeouts the tests after a given time; default is 30000 ms
  • --coverage-exclude or -X, a list of comma-separated patterns to exclude from the coverage report. All tests files are ignored by default.
  • --ignore or -i, ignore a glob pattern, and not look for tests there
  • --expose-gc, exposes the gc() function to tests
  • --pattern or -p, run tests matching the given glob pattern
  • --reporter or -r, set up a reporter, use a colon to set a file destination. Default: spec.
  • --no-typescript or -T, disable automatic TypeScript compilation if tsconfig.json is found.
  • --post-compile or -P, the path to a file that will be executed after each typescript compilation.

Reporters

Here are the available reporters:

  • gh: emits ::error workflow commands for GitHub Actions to show inlined errors. Enabled by default when running on GHA.
  • tap: outputs the test results in the TAP format.
  • spec: outputs the test results in a human-readable format.
  • dot: outputs the test results in a compact format, where each passing test is represented by a ., and each failing test is represented by a X.
  • junit: outputs test results in a jUnit XML format

License

MIT

FAQs

Package last updated on 10 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc