postman-to-mocha-converter
v1.0.0
Published
Converts Postman collections to Mocha test scripts.
Downloads
2
Readme
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
- Clone or download this repository.
- Install the required dependencies:
npm install
- To generate the tests from the Postman collection, run:
node converter.js
- 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.