FREEDOM251

Freedom251 › JavaScript Testing Frameworks

@hapi/lab

Paid

Visit @hapi/lab Alternatives

@hapi/lab's own site

What @hapi/lab is

@hapi/lab is an open-source test utility for Node.js. It organizes tests into experiments, with hooks that run before or after an experiment and before or after each test. Lab supports both BDD-style describe/it and TDD-style suite/test interfaces, and uses async/await with an execution engine designed to remain simple rather than extensible. It works best with @hapi/code, but can also use any assertion library that throws when a condition fails. Lab measures code coverage and can enforce a minimum threshold, with reporters for console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML. TypeScript definitions and a command-line option for TypeScript test files are included. The project was designed for hapi and its components, but can also be used with other frameworks or on its own. Versions 25 and 26 are listed as BSD-licensed and compatible with Node.js 16 or newer. Installation instructions cover npm, Yarn, or pnpm. Support is available free on GitHub, with community assistance through Discord and Slack.

Who it suits

Lab suits Node.js developers who want an experiment-based test utility with coverage reporting. It can be used with hapi, other frameworks, or independently.

What it does well

  • Supports BDD and TDD test interfaces
  • Can enforce a minimum coverage threshold
  • Includes TypeScript definitions
  • Offers seven built-in report formats

What to know first

  • Requires Node.js 16 or newer for versions 25 and 26
  • Does not support parallel execution

Limits

Lab does not support parallel execution. Versions 25 and 26 require Node.js 16 or newer.

Getting started

  1. Install @hapi/lab with npm, Yarn, or pnpm
  2. Create experiments and add before, after, beforeEach, or afterEach hooks
  3. Choose BDD describe/it or TDD suite/test organization
  4. Use @hapi/code or another assertion library that throws on failure
  5. Run TypeScript test files with Lab's command-line option

Verdict

@hapi/lab offers test organization, hooks, coverage, and multiple reporting formats for Node.js projects. Its simple execution design and lack of parallel execution are worth considering.

Questions

Is @hapi/lab free?

Yes. It is free and open source, with a BSD license for listed versions 25 and 26.

Which runtime does Lab support?

Lab supports Node.js. The documentation lists Node.js 16 or newer for major versions 25 and 26.

Can Lab measure coverage?

Yes. It measures coverage and can enforce a minimum threshold, with console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML reports.

Does Lab support TypeScript?

Yes. It includes TypeScript definitions and a command-line option for running TypeScript test files.

How is Lab installed?

The documented installation commands use npm, Yarn, or pnpm.

Does Lab run tests in parallel?

No. Parallel execution is not supported.

Facts from @hapi/lab's own pages

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. · hapi.dev, 8 Oct 2026
Compatibility
The page lists Node.js 16 or newer for major versions 25 and 26, with a BSD license. · hapi.dev, 4 Oct 2026
Compatibility and license
The page lists versions 26 and 25 as BSD-licensed and compatible with Node.js 16 or later. · hapi.dev, 8 Oct 2026
Coverage
Lab can measure code coverage and enforce a minimum coverage threshold. · hapi.dev, 8 Oct 2026
Coverage and reports
Lab supports code coverage and console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML reporters. · hapi.dev, 4 Oct 2026
Design
Lab uses async/await and aims to keep its execution engine simple rather than build an extensible framework. · hapi.dev, 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. · github.com, 4 Oct 2026
Installation
The documented installation commands use npm, Yarn, or pnpm to add @hapi/lab to a project. · hapi.dev, 8 Oct 2026
Purpose
@hapi/lab is a test utility for Node.js. · hapi.dev, 8 Oct 2026
Reporters
Built-in reporters include console, HTML, JSON, JUnit XML, TAP, LCOV, and Clover XML. · hapi.dev, 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. · hapi.dev, 4 Oct 2026
Support
The hapi support page says free help is available through GitHub issues, Discord, and Slack. · hapi.dev, 8 Oct 2026
Test formats
Lab supports BDD-style describe/it and TDD-style suite/test interfaces. · hapi.dev, 8 Oct 2026
Test organization
Tests can be grouped into experiments with before, after, beforeEach, and afterEach setup and cleanup hooks. · hapi.dev, 8 Oct 2026
Test style
Lab uses async/await and describes its execution engine as deliberately simple rather than an extensible framework. · hapi.dev, 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. · hapi.dev, 8 Oct 2026

Where @hapi/lab stands on Freedom251

Look at these too