Looking on the web you can find a few webistes to test out "Structured Data", most of them are mantained by Google but you always need to test manually with different Urls.
I wasn't happy with this workflow that's why I implemented "Structured Data Testing Tool" directly from withing Cypress!
To make it possible I had to follow the following steps:
- Find a node/NPM package to test strucutred data
- Implement a simple "Cypress Plugin" interface to make this package usable from within Cypress
- Finally use the plugin to run this task and test out different pages.
To solve the previous 3 steps we did the following:
- Install the package "structured-data-testing-tool" with
yarn add structured-data-testing-tool
- Create the Cypress Plugin code, you can copy most of the code from the plugins folder here, especially these 2 files:
- Write some tests to test out the plugin: apple-store ✨