This is a demo application showing how to use JSON schemas to validate data flowing in the system.
After cloning the repo, execute from the terminal
npm install
npm run dev
Application should be running at localhost:3000
and Cypress should open.
- See slides for presentation JSON Schemas
- Read JSON Schemas are your True Testing Friend
This project declares the following schemas. Then the schemas are used from the end-to-end tests. Look at the following tests to see how you can use JSON schemas from your tests
- cypress/integration/fixture-spec.js to validate fixture files against a schema
- cypress/integration/api-spec.js validates REST api calls against response schema
- cypress/integration/ui-spec.js drives the web application via DOM UI and validates the Ajax calls from the application to the server using data schema
Example error message when a fixture object does not match the schema
If you use Ramda or lodash/fp you can use curried schema tools functions to create terse functions to validate and sanitize lists of objects. See cypress/integration/ui-spec.js for examples.