{"id":13468214,"url":"https://github.com/pactumjs/pactum","last_synced_at":"2025-05-14T05:10:45.701Z","repository":{"id":37956455,"uuid":"230096072","full_name":"pactumjs/pactum","owner":"pactumjs","description":"REST API Testing Tool for all levels in a Test Pyramid","archived":false,"fork":false,"pushed_at":"2025-02-18T08:35:31.000Z","size":2513,"stargazers_count":569,"open_issues_count":13,"forks_count":56,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-11T00:04:44.673Z","etag":null,"topics":["api-testing","bdd","component-testing","contract-testing","cucumber","e2e-testing","integration-testing","javascript","mock-server","nodejs","pactum","pactumjs","test-pyramid","testing"],"latest_commit_sha":null,"homepage":"https://pactumjs.github.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pactumjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-25T11:53:42.000Z","updated_at":"2025-04-05T02:11:40.000Z","dependencies_parsed_at":"2023-11-10T15:31:36.285Z","dependency_job_id":"4261dbbc-41c4-4e9b-aa6b-674cf32bc9ec","html_url":"https://github.com/pactumjs/pactum","commit_stats":{"total_commits":636,"total_committers":24,"mean_commits":26.5,"dds":"0.13050314465408808","last_synced_commit":"7a692c0a17686b0083117b62055c33c9c6b3e973"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactumjs%2Fpactum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactumjs%2Fpactum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactumjs%2Fpactum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pactumjs%2Fpactum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pactumjs","download_url":"https://codeload.github.com/pactumjs/pactum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254076850,"owners_count":22010611,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-testing","bdd","component-testing","contract-testing","cucumber","e2e-testing","integration-testing","javascript","mock-server","nodejs","pactum","pactumjs","test-pyramid","testing"],"created_at":"2024-07-31T15:01:07.176Z","updated_at":"2025-05-14T05:10:45.675Z","avatar_url":"https://github.com/pactumjs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","testing"],"sub_categories":[],"readme":"\u003cspan align=\"center\"\u003e\n\n![logo](./assets/logo-icon-small.svg)\n\n# PactumJS\n\n![Build](https://github.com/pactumjs/pactum/workflows/Build/badge.svg?branch=master)\n![Coverage](https://img.shields.io/codeclimate/coverage/ASaiAnudeep/pactum)\n![Downloads](https://img.shields.io/npm/dt/pactum)\n![Size](https://img.shields.io/bundlephobia/minzip/pactum)\n![Platform](https://img.shields.io/node/v/pactum)\n\n[![Stars](https://img.shields.io/github/stars/pactumjs/pactum?style=social)](https://github.com/pactumjs/pactum/stargazers)\n[![Twitter](https://img.shields.io/twitter/follow/pactumjs?label=Follow\u0026style=social)](https://twitter.com/pactumjs)\n\n#### REST API Testing Tool for all levels in a Test Pyramid\n\n\u003c/span\u003e\n\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\u003ca href=\"https://pactumjs.github.io\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/pactumjs/pactum/master/assets/demo.gif\" alt=\"PactumJS Demo\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr /\u003e\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n**PactumJS** is a REST API Testing Tool used to automate e2e, integration, contract \u0026 component (*or service level*) tests.\n\n- ⚡ Swift\n- 🎈 Lightweight\n- 🚀 Simple \u0026 Powerful\n- 🛠️ Compelling Mock Server\n- 💎 Elegant Data Management\n- 🔧 Extendable \u0026 Customizable\n- 📚 Clear \u0026 Comprehensive Testing Style\n- 🔗 Component, Contract \u0026 E2E testing of APIs\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n![----------](https://raw.githubusercontent.com/pactumjs/pactum/master/assets/rainbow.png)\n\n## Documentation\n\nThis readme offers an basic introduction to the library. Head over to the full documentation at https://pactumjs.github.io\n\n- [API Testing](https://pactumjs.github.io/guides/api-testing)\n- [Integration Testing](https://pactumjs.github.io/guides/integration-testing)\n- [Component Testing](https://pactumjs.github.io/guides/component-testing)\n- [Contract Testing](https://pactumjs.github.io/guides/contract-testing)\n- [E2E Testing](https://pactumjs.github.io/guides/e2e-testing)\n- [Mock Server](https://pactumjs.github.io/guides/mock-server)\n\n## Need Help\n\nWe use Github [Discussions](https://github.com/pactumjs/pactum/discussions) to receive feedback, discuss ideas \u0026 answer questions.\n\n## Installation\n\n```shell\n# install pactum as a dev dependency\nnpm install --save-dev pactum\n\n# install a test runner to run pactum tests\n# mocha / jest / cucumber\nnpm install --save-dev mocha\n```\n\nor you can simply use\n\n```bash\nnpx pactum-init\n```\n\n![----------](https://raw.githubusercontent.com/pactumjs/pactum/master/assets/rainbow.png)\n\n# Usage\n\n**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.\n\n## API Testing\n\nTests in **pactum** are clear and comprehensive. It uses numerous descriptive methods to build your requests and expectations. \n\n### Simple Test Cases\n\n#### Using Mocha\n\nRunning simple api test expectations.\n\n```js\nconst { spec } = require('pactum');\n\nit('should be a teapot', async () =\u003e {\n  await spec()\n    .get('http://httpbin.org/status/418')\n    .expectStatus(418);\n});\n\nit('should save a new user', async () =\u003e {\n  await spec()\n    .post('https://jsonplaceholder.typicode.com/users')\n    .withHeaders('Authorization', 'Basic xxxx')\n    .withJson({\n      name: 'bolt',\n      email: 'bolt@swift.run'\n    })\n    .expectStatus(200);\n});\n```\n\n```shell\n# mocha is a test framework to execute test cases\nmocha /path/to/test\n```\n\n#### Using Cucumber\n\nSee [pactum-cucumber-boilerplate](https://github.com/pactumjs/pactum-cucumber-boilerplate) for more details on pactum \u0026 cucumber integration.\n\n```gherkin\nScenario: Check Tea Pot\n  Given I make a GET request to \"http://httpbin.org/status/418\"\n  When I receive a response\n  Then response should have a status 418\n```\n\n```js\n// steps.js\nconst pactum = require('pactum');\nconst { Given, When, Then, Before } = require('@cucumber/cucumber');\n\nlet spec = pactum.spec();\n\nBefore(() =\u003e { spec = pactum.spec(); });\n\nGiven('I make a GET request to {string}', function (url) {\n  spec.get(url);\n});\n\nWhen('I receive a response', async function () {\n  await spec.toss();\n});\n\nThen('response should have a status {int}', async function (code) {\n  spec.response().should.have.status(code);\n});\n```\n\n## Mock Server\n\n**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.\n\nRunning **pactum** as a standalone *mock server*.\n\n```js\nconst { mock } = require('pactum');\n\nmock.addInteraction({\n  request: {\n    method: 'GET',\n    path: '/api/projects'\n  },\n  response: {\n    status: 200,\n    body: [\n      {\n        id: 'project-id',\n        name: 'project-name'\n      }\n    ]\n  }\n});\n\nmock.start(3000);\n```\n\n![----------](https://raw.githubusercontent.com/pactumjs/pactum/master/assets/rainbow.png)\n\n# Notes\n\nInspired from [frisby](https://docs.frisbyjs.com/) and [pact](https://docs.pact.io).\n\n## Support\n\nLike this project! Star it on [Github](https://github.com/pactumjs/pactum/stargazers) and follow on [Twitter](https://twitter.com/pactumjs). Your support means a lot to us.\n\n## Contributors\n\nIf you've ever wanted to contribute to open source, and a great cause, now is your chance! See the [contributing docs](https://github.com/pactumjs/pactum/blob/master/CONTRIBUTING.md) for more information.\n\nThanks to all the people who contribute.\n\n\u003ca href=\"https://github.com/pactumjs/pactum/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=pactumjs/pactum\" /\u003e\n\u003c/a\u003e\n\u003cbr /\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpactumjs%2Fpactum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpactumjs%2Fpactum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpactumjs%2Fpactum/lists"}