@useoptic/document-express
v0.2.0
Published
An Optic fixture for documenting Express JS APIs
Downloads
73
Readme
Optic for Express JS
Optic's documenting middleware for Express JS. This package supports APIs written in Javascript, Typescript, or ReasonML and can be used with the testing framework of your choice.
Usage
Install as a dev dependency
npm install @useoptic/document-express --save-dev
Before testing your Express App, wrap it in the documenting middleware.
import withOptic from '@useoptic/document-express'
//Express App used in Production
import {app} from '../server.js'
//Using Optic to document the API as your tests run
const appWithOptic = withOptic(app)
//Example Test
it('can get a list of users', (done) => {
request(appWithOptic)
.get('/users')
.expect(200, done)
})
Consider wrapping the Express App within a shared test fixture so it's easier to integrate Optic with all of your tests.
Next Steps
Once you've setup the documenting middleware, review the Optic docs to finish setting up Optic for your API