Skip to content

Latest commit

 

History

History

metatags

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Metatags

Checkin metatags is really simple with cypress!

Examples

You can find the complete file here: metatags-primary.cy.ts

Testing Page Title

it("tesla.com should have correct title", () => {
  cy.visit("https://www.tesla.com/");
  cy.title().should("eq", "Electric Cars, Solar & Clean Energy | Tesla");
});

Testing Page Canonical

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/"
  );
});

Open Graph Metatags

You can find the complete file here: metatags-opengraph-og.cy.ts

Testing Open Graph og:site_name

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"
  );
});

Twitter Metatags

You can find the complete file here: metatags-twitter.cy.ts

Testing Twitter metatag like twitter:creator

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"
  );
});