# @nomicfoundation/hardhat-mocha

> A mocha test runner

Latest version **4.0.1** (published 2026-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nomicfoundation/hardhat-mocha
pnpm add @nomicfoundation/hardhat-mocha
yarn add @nomicfoundation/hardhat-mocha
bun add @nomicfoundation/hardhat-mocha
```

## Health

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

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

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2026-10-15 |
| First published | 2025-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 5 |
| Unpacked size | 123 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 8521 |
| Author | Nomic Foundation |
| Keywords | ethereum, smart-contracts, hardhat |

## Links

- npm: https://www.npmjs.com/package/@nomicfoundation/hardhat-mocha
- Repository: https://github.com/NomicFoundation/hardhat
- Homepage: https://github.com/NomicFoundation/hardhat/tree/main/packages/hardhat-mocha
- Issues: https://github.com/NomicFoundation/hardhat/issues
- npm.io page: https://npm.io/package/@nomicfoundation/hardhat-mocha

## Dependencies (5)

- [tsx](https://npm.io/package/tsx.md) ^4.23.1
- [zod](https://npm.io/package/zod.md) ^3.23.8
- [@nomicfoundation/hardhat-utils](https://npm.io/package/@nomicfoundation/hardhat-utils.md) ^5.0.0
- [@nomicfoundation/hardhat-errors](https://npm.io/package/@nomicfoundation/hardhat-errors.md) ^3.1.0
- [@nomicfoundation/hardhat-zod-utils](https://npm.io/package/@nomicfoundation/hardhat-zod-utils.md) ^3.0.5

## Recent versions

- 4.0.1 (latest) — 2026-10-15
- 4.0.0 — 2026-09-24
- 3.1.0 — 2026-07-30
- 3.0.21 — 2026-06-04
- 3.0.20 — 2026-05-20
- 3.0.19 — 2026-05-07
- 3.0.18 — 2026-04-30
- 3.0.17 — 2026-04-22
- 3.0.16 — 2026-04-16
- 3.0.15 — 2026-03-31
- 3.0.14 — 2026-03-19
- 3.0.13 — 2026-03-11
- 3.0.12 — 2026-03-05
- 3.0.11 — 2026-02-25
- 3.0.10 — 2026-02-19
- … 43 more at https://npm.io/package/@nomicfoundation/hardhat-mocha/versions

## README

# hardhat-mocha

This plugin integrates [Mocha](https://mochajs.org/) into Hardhat.

## Installation

> This plugin is part of the [Ethers+Mocha Hardhat Toolbox](https://hardhat.org/plugins/nomicfoundation-hardhat-toolbox-mocha-ethers). If you are using that toolbox, there's nothing else you need to do.

To install this plugin, run the following command:

```bash
npm install --save-dev @nomicfoundation/hardhat-mocha
```

In your `hardhat.config.ts` file, import the plugin and add it to the `plugins` array:

```ts
import { defineConfig } from "hardhat/config";
import hardhatMocha from "@nomicfoundation/hardhat-mocha";

export default defineConfig({
  plugins: [hardhatMocha],
});
```

## Usage

This plugin defines a new task called `test mocha` that runs your tests using Mocha. This task gets executed automatically when running `npx hardhat test`.

### Configuration

You can use the `test.mocha` entry in the Hardhat configuration to customize the Mocha options. For example:

```ts
import { defineConfig } from "hardhat/config";

export default defineConfig({
  test: {
    mocha: {
      timeout: 20_000, // set the timeout for tests to 20 seconds
    },
  },
});
```

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