1.0.0 • Published 4 months ago

postman-to-mocha-converter v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

API Test Project

This project is designed to test the API endpoints from a provided Postman collection. The tests are generated dynamically from the Postman collection and include both response data assertions and schema validations.

Project Structure

  • gorest_postman_collection.json: This is the Postman collection from which tests are generated.
  • converter.js: This script converts the Postman collection into Mocha tests with assertions.
  • helper.js: Contains helper functions to send requests and manage the API base URL.
  • data/dataSchema.js: Contains the inferred JSON schemas for each endpoint from the Postman collection.
  • test/testScenario.test.js: Contains the generated Mocha tests.

Getting Started

  1. Clone or download this repository.
  2. Install the required dependencies:
npm install
  1. To generate the tests from the Postman collection, run:
node converter.js
  1. To run the generated tests, use:
npm test

Dependencies

  • chai: Assertion library used for writing the tests.
  • ajv: JSON schema validator used for validating API responses against inferred schemas.

Notes

  • The tests are generated based on the provided Postman collection. If the API responses change, you might need to update the Postman collection and regenerate the tests.
  • Schema validations are inferred from the sample responses in the Postman collection. They provide basic structure validations and may need refinement for more comprehensive validations.