@hapi/lab
@hapi/lab is a free, open-source test utility for Node.js.
What @hapi/lab is
@hapi/lab is a free, open-source test utility for Node.js. It organizes tests into experiments and supports before, after, beforeEach, and afterEach hooks. Tests can use BDD-style describe/it or TDD-style suite/test interfaces. Lab uses async/await and keeps its execution engine deliberately simple rather than serving as an extensible framework. It works best with @hapi/code, but accepts any assertion library that throws when a condition fails. Coverage measurement can enforce a minimum threshold, with built-in console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML reporters. TypeScript definitions and a command-line option for TypeScript test files are included. Versions 25 and 26 are listed for Node.js 16 or newer under a BSD license. Installation documentation uses npm, Yarn, or pnpm. Lab does not support parallel execution.
Good
- Async/await test execution
- BDD and TDD test interfaces
- Coverage thresholds and many reporters
- TypeScript definitions and CLI support
- BSD-licensed open source
Watch out
- No parallel execution
- Node.js 16 or newer for versions 25 and 26
- Designed around a simple, non-extensible engine
Who it suits
@hapi/lab suits Node.js developers who want experiment-based tests, async/await, coverage checks, and multiple report formats. It is designed for hapi components but can also run with other frameworks or independently.
Verdict
@hapi/lab provides a focused Node.js test runner with hooks, coverage controls, TypeScript support, and broad reporting formats. Its deliberate simplicity and lack of parallel execution are important when choosing a testing utility.
The facts
Each one read from @hapi/lab's own pages, with the date it was checked.
What it does
- Assertions
- Lab works best with the @hapi/code assertion library, but can be used with any assertion library that throws when a condition is not met.checked 8 Oct 2026
- Compatibility
- The page lists Node.js 16 or newer for major versions 25 and 26, with a BSD license.checked 4 Oct 2026
- Compatibility and license
- The page lists versions 26 and 25 as BSD-licensed and compatible with Node.js 16 or later.checked 8 Oct 2026
- Coverage
- Lab can measure code coverage and enforce a minimum coverage threshold.checked 8 Oct 2026
- Coverage and reports
- Lab supports code coverage and console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML reporters.checked 4 Oct 2026
- Design
- Lab uses async/await and aims to keep its execution engine simple rather than build an extensible framework.checked 4 Oct 2026
- Ecosystem
- The project says Lab was designed to work with the hapi framework and its components, and also works with other frameworks or on its own.checked 4 Oct 2026
- Installation
- The documented installation commands use npm, Yarn, or pnpm to add @hapi/lab to a project.checked 8 Oct 2026
- Purpose
- @hapi/lab is a test utility for Node.js.checked 8 Oct 2026
- Reporters
- Built-in reporters include console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML.checked 8 Oct 2026
- Security reporting
- The hapi security policy asks people to report suspected security issues with hapi modules privately to [email protected] rather than opening public issues.checked 4 Oct 2026
- Support
- The hapi support page says free help is available through GitHub issues, Discord, and Slack.checked 8 Oct 2026
- Test formats
- Lab supports BDD-style describe/it and TDD-style suite/test interfaces.checked 8 Oct 2026
- Test organization
- Tests can be grouped into experiments with before, after, beforeEach, and afterEach setup and cleanup hooks.checked 8 Oct 2026
- Test style
- Lab uses async/await and describes its execution engine as deliberately simple rather than an extensible framework.checked 8 Oct 2026
- TypeScript
- Lab includes TypeScript definitions and has a CLI option to run TypeScript test files using the project’s TypeScript module and configuration.checked 8 Oct 2026
Alternatives to @hapi/lab
- 1

QUnit
Free planAndroidiOSWebAPI7.4Free plan - 2

Web Test Runner
Free planWebLinuxmacOSSelf-hosted6.9Free plan - 3

Cucumber.js
Free planLinuxmacOSSelf-hostedWindows6.8Free plan - 4
Karma
Free planAndroidiOSWebLinux6.7Free plan - 5

Vitest
Free planWebLinuxmacOSWindows6.6Free plan - 6
Jasmine
Free planWebLinuxmacOSWindows6.5Free plan
