Mocking and testing utilities for developing APIs with Swagger/OpenAPI
Run a mock server
The following example starts a mock server that hosts each of the spec files in the specified folder. The server will restart when any of the spec files are updated. The regex determines which files should be run. But default, any file ending with
.oas2.json will be run.
const watch = ;;
Generate integration tests
The following example will generate Mocha tests for negative cases based on the provided specs. The tests can then be run as you would run any suite of Mocha tests.
const fs = ;constcreateTestCasescreateBadParameterscreateMethodNotAllowedcreateMissingParameterscreateSmokeTestsgenerate= ;const spec = fs;;
Run this project
- Build the code:
npm run build
- Run it!
Create and run tests
- Add tests by creating files with the
- Run the tests:
- Test coverage can be viewed at