ACT 1: EXPOSITION
I am thrilled to introduce the new CYPRESS-SCHEMA-VALIDATOR plugin, the ultimate successor to CYPRESS-AJV-SCHEMA-VALIDATOR! Combining all the power of AJV schema validation from its predecessor and now also featuring ZOD Schema Validation, and new features. 🔥 🔥 🔥
The CYPRESS-SCHEMA-VALIDATOR is fully backward-compatible with the previous version, and continues to integrate smoothly with leading Cypress API plugins like @bahmutov/cy-api
and cypress-plugin-api
.
This new version represents a significant leap forward in flexibility, usability, and debugging efficiency.
ACT 2: CONFRONTATION
🤔 What’s New?
- Support for Both AJV and ZOD Validators: Choose between AJV and ZOD for schema validation, offering versatility for diverse workflows.
-
Terminal Display of Schema Errors: Schema errors are now shown directly in the terminal during
run
mode, simplifying debugging.
- Customizable Styles: Add a personalized touch by using custom icons and HEX colors to better distinguish validation issues.
- Consistent Error Format: Enjoy unified error formatting, regardless of the validator selected (AJV or ZOD), for seamless and clear reporting during testing.
⏮️ Fully Backward Compatible?
AFFIRMATIVE! 🤟🤟🤟
🛸 How Do I Migrate?
Upgrading your Cypress framework from CYPRESS-AJV-SCHEMA-VALIDATOR to the new CYPRESS-SCHEMA-VALIDATOR is as simple as this:
1) Uninstall the previous plugin:
npm uninstall cypress-ajv-schema-validator
2) Install the new plugin:
npm install -D cypress-schema-validator
3) Replace previous imports in your project:
Replace:
import 'cypress-ajv-schema-validator'
With:
import 'cypress-schema-validator'
✔️ What About the existing .validateSchema()
Command In My Code?
No worries, you don’t need to refactor your test cases beyond the imports!
The
.validateSchema()
command still works with AJV schemas.A new alias,
.validateSchemaAjv()
, is also available for AJV validation.Additionally, the plugin introduces
.validateSchemaZod()
for ZOD schema validation.
That's it, NO DRAMA-LAMA! 🦙🦙🦙
If you're looking for drama, check out my article series: The Test Drama: Cypress and Playwright, Who Steals the Show? 😁
ACT3: RESOLUTION
Don't wait! Upgrade your Cypress framework with the new CYPRESS-SCHEMA-VALIDATOR and enjoy unparalleled flexibility for schema validations using two of the most powerful validators available today: AJV and ZOD (plus many other perks).
You can find it in:
- npm: https://www.npmjs.com/package/cypress-schema-validator
- GitHub: https://github.com/sclavijosuero/cypress-schema-validator
I'd love to hear from you! Please don't forget to follow me, leave a comment, or a reaction if you found this article useful or insightful. ❤️ 🦄 🤯 🙌 🔥
You can also connect with me on my new YouTube channel: https://www.youtube.com/@SebastianClavijoSuero
If you'd like to support my work, consider buying me a coffee or contributing to a training session, so I can keep learning and sharing cool stuff with all of you.
Thank you for your support!
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more