@hapi/lab
hapi.dev
What @hapi/lab is
@hapi/lab is a free, open-source test utility for Node.js. It organizes tests into experiments and provides 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 simple rather than building 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 and produce console, HTML, JSON, JUnit XML, TAP, LCOV, or Clover XML reports. TypeScript definitions are included, with a command-line option for TypeScript test files. Designed for hapi and its components, Lab also works with other frameworks or alone. Documentation lists versions 25 and 26 for Node.js 16 or newer under a BSD license. Installation uses npm, Yarn, or pnpm. Lab does not support parallel execution.
Who it suits
Lab suits Node.js developers building tests for hapi projects or other frameworks. It is useful when teams need hooks, coverage thresholds, TypeScript support, and multiple report formats.
Good to know, and what to watch
- Open-source BSD-licensed utility
- Supports BDD and TDD interfaces
- Coverage thresholds and many reporters
- Includes TypeScript definitions
- Works with other frameworks
- No parallel test execution
- Execution engine is not extensible
- Best compatibility is with @hapi/code
The verdict
Lab provides a focused Node.js testing workflow with hooks, coverage controls, TypeScript support, and broad reporting. Teams needing parallel execution or an extensible engine should account for its stated limits.
What the maker publishes
- Assertions
- Lab works best with @hapi/code, but can be used with any assertion library that throws when a condition is not met. source
- 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. source
- Compatibility
- The page lists Node.js 16 or newer for major versions 25 and 26, with a BSD license. source
- Compatibility and license
- The page lists versions 26 and 25 as BSD-licensed and compatible with Node.js 16 or later. source
- Coverage
- Lab can measure code coverage and enforce a minimum coverage threshold. source
- Coverage and reports
- Lab supports code coverage and console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML reporters. source
- Design
- Lab uses async/await and aims to keep its execution engine simple rather than build an extensible framework. source
- 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. source
- Installation
- The documented installation commands use npm, Yarn, or pnpm to add @hapi/lab to a project. source
- Purpose
- @hapi/lab is a test utility for Node.js. source
- Purpose
- @hapi/lab is a test utility for Node.js. source
- Reporters
- Built-in reporters include console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML. source
- 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. source
- Support
- The hapi support page says free support is available on GitHub, with community help also available through Discord and Slack. source
- Support
- The hapi support page says free help is available through GitHub issues, Discord, and Slack. source
- Test formats
- Lab supports BDD-style describe/it and TDD-style suite/test interfaces. source
- Test organization
- Tests can be grouped into experiments with before, after, beforeEach, and afterEach hooks. source
- Test organization
- Tests can be grouped into experiments with before, after, beforeEach, and afterEach setup and cleanup hooks. source
- Test style
- Lab uses async/await and describes its execution engine as deliberately simple rather than an extensible framework. source
- TypeScript
- Lab includes TypeScript definitions and a CLI option for running TypeScript test files. source
- TypeScript
- Lab includes TypeScript definitions and has a CLI option to run TypeScript test files using the project’s TypeScript module and configuration. source
Checked against the maker's pages on 8 Oct 2026.