{"library":"pactum","title":"PactumJS REST API Testing Tool","description":"PactumJS is a lightweight and powerful open-source REST API testing tool designed to automate various levels of API testing, including end-to-end (e2e), integration, contract, and component (service level) tests. It emphasizes a clear and comprehensive testing style, utilizing numerous descriptive methods for building requests and defining expectations. The current stable version is 3.9.1, with minor releases occurring frequently, demonstrating active development and maintenance. Key differentiators include its compelling built-in mock server, elegant data management capabilities for dynamic values, robust built-in JSON schema validation, and an extendable architecture. PactumJS supports various JavaScript test runners like Mocha, Jest, and Cucumber, making it adaptable to different testing frameworks and helping simplify complex API testing scenarios across the entire test pyramid.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install pactum"],"cli":null},"imports":["import { spec } from 'pactum'","import * as pactum from 'pactum'","import type { Spec } from 'pactum'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { spec } from 'pactum';\n\ndescribe('HTTPBin API Tests', () => {\n  it('should respond with a 418 status code (teapot)', async () => {\n    await spec()\n      .get('http://httpbin.org/status/418')\n      .expectStatus(418);\n  });\n\n  it('should save a new user via POST request', async () => {\n    // In a real scenario, use process.env.AUTH_TOKEN or a secure method for credentials\n    const authToken = process.env.TEST_AUTH_TOKEN ?? 'Basic aHR0cGJpbjpwYXNzd29yZA==';\n\n    await spec()\n      .post('https://jsonplaceholder.typicode.com/users')\n      .withHeaders('Authorization', authToken)\n      .withJson({\n        name: 'John Doe',\n        email: 'john.doe@example.com',\n        username: 'johndoe'\n      })\n      .expectStatus(201) // POST to /users typically returns 201 Created\n      .expectJsonMatch({ name: 'John Doe', email: 'john.doe@example.com' });\n  });\n});\n","lang":"typescript","description":"Demonstrates basic GET and POST requests, status code assertions, and JSON body matching using PactumJS with an ESM setup and environment variable for authentication.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}