DEV.co
Open-Source Testing · pactumjs

pactum

PactumJS is a lightweight Node.js REST API testing tool that supports all testing pyramid levels—unit, integration, component, contract, and e2e—plus a standalone mock server. It uses a fluent API style with Mocha or Cucumber integration and requires minimal setup.

Source: GitHub — github.com/pactumjs/pactum
617
GitHub stars
62
Forks
JavaScript
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositorypactumjs/pactum
Ownerpactumjs
Primary languageJavaScript
LicenseMIT — OSI-approved
Stars617
Forks62
Open issues18
Latest releasev3.9.1 (2026-02-27)
Last updated2026-06-30
Sourcehttps://github.com/pactumjs/pactum

What pactum is

PactumJS provides a spec-based HTTP testing DSL for Node.js, with request/response builders, mock server capabilities, contract testing support, and data management features. Built in JavaScript, it integrates with common test runners and supports BDD patterns via Cucumber.

Quickstart

Get the pactum source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/pactumjs/pactum.gitcd pactum# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Contract Testing Between Microservices

Use PactumJS's mock server and contract testing features to validate API contracts between service boundaries without deploying all services together, reducing integration testing friction.

Multi-Level API Test Pyramid

Write component-level, integration, and e2e tests for REST APIs in a single framework with consistent syntax, reducing context switching and test suite fragmentation.

Standalone Mock Server for Development

Deploy PactumJS as a lightweight HTTP mock server to unblock frontend/client teams while backend services are under development, with no external dependencies.

Implementation considerations

  • Install as dev dependency and pair with a test runner (Mocha, Jest, or Cucumber); use `npx pactum-init` for quick scaffolding.
  • Mock server runs in-process or as standalone; plan resource isolation and port allocation if running multiple instances in CI/CD.
  • Data management (fixtures, templates) must be defined in test code or external JSON; no built-in database or state persistence layer.
  • Request/response matching uses simple equality and regex patterns; complex validation logic requires custom assertions or helper functions.
  • GitHub Discussions is the primary support channel; no SLA or commercial support evident from metadata.

When to avoid it — and what to weigh

  • Non-REST API Requirements — PactumJS is REST-focused. If your testing needs involve gRPC, WebSockets, GraphQL, or other protocol stacks, evaluate alternatives designed for those protocols.
  • Heavy Load/Performance Testing — PactumJS is not positioned as a load testing or performance benchmarking tool. Use dedicated tools (k6, JMeter, Gatling) for stress and scale testing.
  • Minimal Team JavaScript Expertise — PactumJS requires Node.js/JavaScript familiarity and a compatible test runner setup. Teams with no JavaScript experience may face steeper onboarding.
  • Complex State Synchronization Across Services — For deeply stateful, distributed system testing with complex orchestration, dedicated tools with richer state management may be better suited than API mocking alone.

License & commercial use

MIT License permits commercial and proprietary use, modification, and distribution with attribution and inclusion of the license text. No restrictions on closed-source derivative works.

MIT is a permissive OSI-approved license explicitly allowing commercial use. No commercial support, SLAs, or vendor tie-in evident from the project; use at own risk in production contexts.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

PactumJS is a testing tool operating in dev/test environments, not production. Standard Node.js dependency audit practices apply (npm audit). Mock server should not be exposed to untrusted networks without additional authentication. No security advisories or CVEs evident in provided data; third-party dependencies require separate review.

Alternatives to consider

Frisby.js

Similar fluent API for REST testing; lighter footprint but less mature mock server and contract testing support. PactumJS explicitly acknowledges Frisby as inspiration.

Jest + Supertest

Built-in Jest matchers with Supertest HTTP assertions; tightly integrated with Jest ecosystem but requires more manual setup for mock servers and contract testing than PactumJS.

Postman/Newman

GUI and CLI API testing with broader enterprise adoption and cloud integrations; heavier footprint, less code-centric than PactumJS, steeper learning curve for developers.

Software development agency

Build on pactum with DEV.co software developers

PactumJS combines contract, integration, and e2e testing in one lightweight framework. Get started with npm install and explore the documentation at pactumjs.github.io.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

pactum FAQ

Does PactumJS work with TypeScript?
Not explicitly stated in provided data. Requires review of package contents and community discussions to confirm TypeScript support or type definitions.
Can PactumJS mock GraphQL or WebSocket endpoints?
No. PactumJS is REST-focused; GraphQL and WebSocket support not mentioned. Use protocol-specific tools if needed.
Is there a paid support or SLA option?
Not evident from GitHub metadata. Support appears community-driven via GitHub Discussions. For production SLAs, contact maintainers or seek commercial alternatives.
Can PactumJS generate test reports for CI/CD?
Not clearly stated. Integration depends on the test runner (Mocha, Jest, Cucumber) and custom reporting; requires documentation or code review.

Work with a software development agency

DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If pactum is part of your open-source testing roadmap, our team can implement, customize, migrate, and maintain it.

Ready to Streamline Your API Testing?

PactumJS combines contract, integration, and e2e testing in one lightweight framework. Get started with npm install and explore the documentation at pactumjs.github.io.