All Projects → pactumjs → pactum

pactumjs / pactum

Licence: MIT license
REST API Testing Tool for all levels in a Test Pyramid

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pactum

Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+2793.16%)
Mutual labels:  bdd, mock-server, cucumber, api-testing, contract-testing
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+3260%)
Mutual labels:  bdd, mock-server, cucumber, api-testing, contract-testing
karate-runner
VSCode Extension for Karate
Stars: ✭ 23 (-87.89%)
Mutual labels:  bdd, cucumber, api-testing, contract-testing
Godog
Cucumber for golang
Stars: ✭ 1,287 (+577.37%)
Mutual labels:  bdd, integration-testing, cucumber
Stubby4j
An HTTP stub server for testing application interactions with web services (REST, etc) & external system stubbing for easy testing
Stars: ✭ 300 (+57.89%)
Mutual labels:  integration-testing, mock-server, api-testing
portman
Port OpenAPI Specs to Postman Collections, inject test suite and run via Newman 👨🏽‍🚀
Stars: ✭ 530 (+178.95%)
Mutual labels:  integration-testing, api-testing, contract-testing
demo-webdriverio-cucumber
E2E Tests with WebdriverIO and Cucumber
Stars: ✭ 28 (-85.26%)
Mutual labels:  bdd, integration-testing, cucumber
mocha-cakes-2
A BDD plugin for Mocha testing framework
Stars: ✭ 44 (-76.84%)
Mutual labels:  bdd, cucumber
kekiri
A .NET framework that supports writing low-ceremony BDD tests using Gherkin language
Stars: ✭ 19 (-90%)
Mutual labels:  bdd, cucumber
cucumber-performance
A performance testing framework for cucumber
Stars: ✭ 28 (-85.26%)
Mutual labels:  bdd, cucumber
codeceptjs-bdd
Javascript BDD UI Automation Framework. Exclusive LWC Shadow DOM Support. Playwright, Webdriver.io, Appium, Saucelabs.
Stars: ✭ 35 (-81.58%)
Mutual labels:  bdd, cucumber
api-test
🌿 A simple bash script to test JSON API from terminal in a structured and organized way.
Stars: ✭ 53 (-72.11%)
Mutual labels:  integration-testing, api-testing
irontest
A web app for API test automation
Stars: ✭ 31 (-83.68%)
Mutual labels:  integration-testing, api-testing
cucumber6-ts-starter
Starter project to write and debug cucumber-js features in TypeScript language
Stars: ✭ 62 (-67.37%)
Mutual labels:  bdd, cucumber
cypress-upload-file-post-form
Solution for two Cypress testing use-cases I came across with: perform a direct http FORM request to the server containing a file and other parameters and upload a file into a form before submission
Stars: ✭ 59 (-68.95%)
Mutual labels:  api-testing, e2e-testing
chuck
Lightweight proxy for REST API mocking and run integration test on mobile devices
Stars: ✭ 17 (-91.05%)
Mutual labels:  integration-testing, mock-server
NScenario
Dead simple library for annotating steps of test case scenarios.
Stars: ✭ 58 (-69.47%)
Mutual labels:  integration-testing, component-testing
Awesome-Cucumber
A collection of awesome Cucumber and Gherkin-related resources
Stars: ✭ 33 (-82.63%)
Mutual labels:  bdd, cucumber
software-testing-resource-pack
Various files useful for manual testing and test automation etc.
Stars: ✭ 38 (-80%)
Mutual labels:  api-testing, e2e-testing
sample-testing-microservices
sample applications with implementation of unit, component, contract and integrarion tests using pact, gatling, spring boot test and hoverfly
Stars: ✭ 22 (-88.42%)
Mutual labels:  contract-testing, component-testing

logo

PactumJS

Build Coverage Downloads Size Platform

Stars Twitter

REST API Testing Tool for all levels in a Test Pyramid


PactumJS Demo


PactumJS is a REST API Testing Tool used to automate e2e, integration, contract & component (or service level) tests.

  • Swift
  • 🎈 Lightweight
  • 🚀 Simple & Powerful
  • 🛠️ Compelling Mock Server
  • 💎 Elegant Data Management
  • 🔧 Extendable & Customizable
  • 📚 Clear & Comprehensive Testing Style
  • 🔗 Component, Contract & E2E testing of APIs

----------

Documentation

This readme offers an basic introduction to the library. Head over to the full documentation at https://pactumjs.github.io

Need Help

We use Github Discussions to receive feedback, discuss ideas & answer questions.

Installation

# install pactum as a dev dependency
npm install --save-dev pactum

# install a test runner to run pactum tests
# mocha / jest / cucumber
npm install --save-dev mocha

----------

Usage

pactum can be used for all levels of testing in a test pyramid. It can also act as an standalone mock server to generate contracts for contract testing.

API Testing

Tests in pactum are clear and comprehensive. It uses numerous descriptive methods to build your requests and expectations.

Simple Test Cases

Using Mocha

Running simple api test expectations.

const pactum = require('pactum');

it('should be a teapot', async () => {
  await pactum.spec()
    .get('http://httpbin.org/status/418')
    .expectStatus(418);
});

it('should save a new user', async () => {
  await pactum.spec()
    .post('https://jsonplaceholder.typicode.com/users')
    .withHeaders('Authorization', 'Basic xxxx')
    .withJson({
      name: 'bolt',
      email: '[email protected]'
    })
    .expectStatus(200);
});
# mocha is a test framework to execute test cases
mocha /path/to/test

Using Cucumber

See pactum-cucumber-boilerplate for more details on pactum & cucumber integration.

Scenario: Check Tea Pot
  Given I make a GET request to "http://httpbin.org/status/418"
  When I receive a response
  Then response should have a status 418
// steps.js
const pactum = require('pactum');
const { Given, When, Then, Before } = require('@cucumber/cucumber');

let spec = pactum.spec();

Before(() => { spec = pactum.spec(); });

Given('I make a GET request to {string}', function (url) {
  spec.get(url);
});

When('I receive a response', async function () {
  await spec.toss();
});

Then('response should have a status {int}', async function (code) {
  spec.response().should.have.status(code);
});

Mock Server

pactum can act as a standalone mock server that allows us to mock any server via HTTP or HTTPS, such as a REST endpoint. Simply it is a simulator for HTTP-based APIs.

Running pactum as a standalone mock server.

const { mock } = require('pactum');

mock.addInteraction({
  request: {
    method: 'GET',
    path: '/api/projects'
  },
  response: {
    status: 200,
    body: [
      {
        id: 'project-id',
        name: 'project-name'
      }
    ]
  }
});

mock.start(3000);

----------

Notes

Inspired from frisby and pact.

Support

Like this project! Star it on Github and follow on Twitter. Your support means a lot to us.

Contributors

If you've ever wanted to contribute to open source, and a great cause, now is your chance! See the contributing docs for more information.

Thanks to all the people who contribute.


Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].