Some examples of things you can do in a front end project with Prism, an OpenAPI mocking server.
- Node v10+
- NPM v6+
- Docker
npm install
This example contains 2 processes:
- A Nuxt.js (Vue.js framework) application.
- A Prism mocking server.
There are several scenario's of how you can run de example code:
Start up both processes through npm.
npm run dev:all
Run only the Nuxt.js application.
npm run dev
Run only the Prism mock.
npm run mocks
# With a watcher on the OpenAPI document
npm run mocks:watch
If the default Prism functionality doesn't meet your requirements, you could run Prism programmatically and plugin on the Fastify instance that Prism uses as server.
npm run mocks:advanced
# With a watcher on the OpenAPI document
npm run mocks:advanced:watch
The command will run the mocks/runner.js
with Node.
Prism also provides a Docker image on which you can mock your OpenAPI document.
docker run --rm -it -p 4010:4010 -v $(pwd):/tmp stoplight/prism:3 mock -d -h 0.0.0.0 "mocks/prism.js"
This example uses Cypress for integration/e2e
Start the Cypress UI
npx cypress open
Run Cypress in the CLI
npx cypress run
All Cypress related files are located in the cypress
folder.