# @tapjs/mocha-globals

> An optional plugin adding Mocha-like BDD and TDD interfaces to the global environment when tap is loaded.

Latest version **4.3.12** (published 2026-09-03) · BlueOak-1.0.0 license · 0 weekly downloads

## Install

```sh
npm install @tapjs/mocha-globals
pnpm add @tapjs/mocha-globals
yarn add @tapjs/mocha-globals
bun add @tapjs/mocha-globals
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.3.12 |
| Published | 2026-09-03 |
| First published | 2023-09-05 |
| Weekly downloads | 0 |
| License | BlueOak-1.0.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | 20 \|\| >=22 |
| Dependencies | 6 |
| Unpacked size | 75.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2423 |
| Author | Isaac Z. Schlueter |
| Maintainers | ljharb, isaacs |
| Keywords | tapjs plugin |

## Links

- npm: https://www.npmjs.com/package/@tapjs/mocha-globals
- Repository: https://github.com/tapjs/tapjs
- Homepage: https://github.com/tapjs/tapjs/tree/main/src/mocha-globals#readme
- Issues: https://github.com/tapjs/tapjs/issues
- Funding: https://github.com/sponsors/isaacs
- npm.io page: https://npm.io/package/@tapjs/mocha-globals

## Dependencies (6)

- [@tapjs/after](https://npm.io/package/@tapjs/after.md) 3.3.12
- [@tapjs/stack](https://npm.io/package/@tapjs/stack.md) 4.3.3
- [@tapjs/before](https://npm.io/package/@tapjs/before.md) 4.3.12
- [@tapjs/after-each](https://npm.io/package/@tapjs/after-each.md) 4.3.12
- [is-actual-promise](https://npm.io/package/is-actual-promise.md) ^1.0.1
- [@tapjs/before-each](https://npm.io/package/@tapjs/before-each.md) 4.3.12

## Recent versions

- 4.3.12 (latest) — 2026-09-03
- 1.0.0 (pre) — 2023-09-15
- 4.3.11 — 2026-07-27
- 4.3.10 — 2026-05-15
- 4.3.9 — 2026-05-13
- 4.3.8 — 2026-05-01
- 4.3.7 — 2026-04-17
- 4.3.6 — 2026-04-15
- 4.3.5 — 2026-04-05
- 4.3.4 — 2026-02-20
- 4.3.3 — 2026-02-18
- 4.3.2 — 2026-02-18
- 4.3.1 — 2026-02-05
- 4.3.0 — 2025-12-01
- 4.2.1 — 2025-11-26
- … 56 more at https://npm.io/package/@tapjs/mocha-globals/versions

## README

# `@tapjs/mocha-globals`

An optional plugin adding Mocha-like BDD and TDD interfaces to
the global environment when tap is loaded.

To install it, run:

```
tap plugin add @tapjs/mocha-globals
```

## API

The goal of this plugin is _not_ to fully implement the Mocha
interface with perfect fidelity, but rather to facilitate porting
tests to use tap from other test framework dialects, and to
provide this interface for those who prefer this style.

TDD/BDD methods provided:

- `describe(fn)` _(alias: `context()`, `suite()`)_
- `it(fn)` _(alias: `specify()`, `test()`)_
- `before(fn)` _(alias: `suiteSetup()`)_
- `after(fn)` _(alias: `suiteTeardown()`)_
- `beforeEach(fn)` _(alias: `setup()`)_
- `afterEach(fn)` _(alias: `teardown()`)_

Other useful things that are helpful with these:

### `tt() => Test`

Return the tap `Test` object that corresponds to the current
suite or test that the mocha BDD/TDD methods are running.

### `currentSuite() => Test`

The `Test` corresponding to the current `describe()` block, or
undefined outside of a suite.

### `currentTest() => Test`

The `Test` corresponding to the current `it()` block, or
undefined outside of a test.

### `mounted() => Test`

The `Test` corresponding to the "root" where all suites branch
off from.

When the plugin is active, this is always the `TAP` root test
object.

### `globalize()`

Set all the BDD/TDD methods in the global space.

## Config

If the `--mocha-globals` flag is set (true by default) then these
methods will be injected into the global space.

If disabled with `--no-mocha-globals` on the command line or
`mocha-globals: false` in a `.taprc`, then you can import them
from `@tapjs/mocha-globals` as named exports.

---
_Source: https://npm.io/package/@tapjs/mocha-globals · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
