Last active
November 11, 2021 19:25
-
-
Save dannyshain/d13c51bf1cb6c1c2507d50a95ba06515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("Verify jsonLD structured data - simple", () => { | |
// Query the script tag with type application/ld+json | |
cy.get("script[type='application/ld+json']").then((scriptTag) => { | |
// we need to parse the JSON-LD from text to a JSON to easily test it | |
const jsonLD = JSON.parse(scriptTag.text()); | |
// once parsed we can easily test for different data points | |
expect(jsonLD["@context"]).equal("https://schema.org"); | |
expect(jsonLD.author).length(2); | |
// Cross-referencing SEO data between the page title and the headline | |
// in the jsonLD data, great for dynamic data | |
cy.title().then((currentPageTitle) => | |
expect(jsonLD["headline"]).equal(currentPageTitle) | |
); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment