https://github.com/taylorgoolsby/boxtape
A tape testing framework with defaults
https://github.com/taylorgoolsby/boxtape
esm tap tape testing
Last synced: 10 months ago
JSON representation
A tape testing framework with defaults
- Host: GitHub
- URL: https://github.com/taylorgoolsby/boxtape
- Owner: taylorgoolsby
- Created: 2023-07-04T02:20:52.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-07T00:16:52.000Z (almost 3 years ago)
- Last Synced: 2025-08-29T21:04:48.778Z (10 months ago)
- Topics: esm, tap, tape, testing
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/boxtape
- Size: 240 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 📦 boxtape
This is just regular tape, but with some quality of life improvements for the ESM era.
## Usage
See [tape](https://www.npmjs.com/package/tape).
```shell
npm install boxtape
# If you use typescript:
npm install @types/tape
```
```shell
boxtape tests/**/*.js
```
```js
import test from 'boxtape'
```
## Additions
### `beforeEach`
```js
import test from 'boxtape'
test.beforeEach(async (t) => {
// Do something before each test.
})
```
### `afterEach`
```js
import test from 'boxtape'
test.afterEach(async (t) => {
// Do something after each test.
})
```
### Default TAP Output Formatter
This uses a fork of [`tap-pretty`](https://www.npmjs.com/package/tap-pretty) to provide a nice output by default. The fork has added error stack trace so that you can navigate to where the error occurred.

Since `boxtape` automatically pipes `tape` output into `tap-pretty`, you cannot pipe into your own tap formatter.
## Examples
### Frontend Testing
Here is a simple example to get you started for frontend testing.
```js
// In this example, we are doing some frontend testing.
import test from 'boxtape'
import sinon from 'sinon'
import {JSDOM} from 'jsdom'
// Load DOM functions:
const dom = new JSDOM()
global.document = dom.window.document
global.window = dom.window
sinon.spy(document)
test.beforeEach(() => {
// Maybe you want to reset your spy counts:
for (const method in document) {
if (typeof document[method] === 'function') {
if (document[method].callCount !== undefined) {
document[method].callCount = 0
}
}
}
})
```