Checkin metatags is really simple with cypress!
- Primary Metatags: check title and metatags for title and description ✨
- Open Graph Metatags: check og or opengraph metatags ✨
- Twitter Metatags: check twitter metatags for twitter card previews ✨
You can find the complete file here: metatags-primary.cy.ts ✨
it("tesla.com should have correct title", () => {
cy.visit("https://www.tesla.com/");
cy.title().should("eq", "Electric Cars, Solar & Clean Energy | Tesla");
});
it("tesla.com should have correct canonical", () => {
cy.visit("https://www.tesla.com/");
cy.get('head link[rel="canonical"]').should(
"have.attr",
"href",
"https://www.tesla.com/"
);
});
You can find the complete file here: metatags-opengraph-og.cy.ts ✨
it("tesla.com should have correct og:site_name", () => {
cy.visit("https://www.tesla.com/");
cy.get('head meta[property="og:site_name"]').should(
"have.attr",
"content",
"Tesla"
);
});
You can find the complete file here: metatags-twitter.cy.ts ✨
it("tesla.com should have correct twitter:creator", () => {
cy.visit("https://www.tesla.com/");
cy.get('head meta[name="twitter:creator"]').should(
"have.attr",
"content",
"@tesla"
);
});