-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first tests with structured-data-testing-tool
- Loading branch information
1 parent
3a0c03c
commit 0ddf0ba
Showing
5 changed files
with
578 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
describe("Apple Structured Data, Schema.org or JSON-LD", () => { | ||
it("apple homepage has WebPage, Organization and Website ", () => { | ||
cy.visit("https://www.apple.com"); | ||
cy.task("structuredData", { | ||
url: "https://www.apple.com", | ||
schemas: ["WebPage", "Organization", "WebSite"], | ||
}).then((result) => { | ||
expect(result.passed.length).to.equal(3); | ||
}); | ||
}); | ||
it("apple iphone 12 has BreadcrumbList and Product ", () => { | ||
cy.visit("https://www.apple.com/iphone-12"); | ||
cy.task("structuredData", { | ||
url: "https://www.apple.com/iphone-12", | ||
schemas: ["BreadcrumbList", "Product"], | ||
}).then((result) => { | ||
expect(result.passed.length).to.equal(2); | ||
expect(result.passed[0].schema).to.equal("BreadcrumbList"); | ||
expect(result.passed[1].schema).to.equal("Product"); | ||
}); | ||
}); | ||
it("apple iphone 12 shop page has BreadcrumbList, Product and FAQPage ", () => { | ||
cy.task("structuredData", { | ||
url: "https://www.apple.com/shop/buy-iphone/iphone-12", | ||
schemas: ["BreadcrumbList", "Product", "FAQPage"], | ||
}).then((result) => { | ||
expect(result.passed.length).to.equal(3); | ||
expect(result.passed[0].schema).to.equal("BreadcrumbList"); | ||
expect(result.passed[1].schema).to.equal("Product"); | ||
expect(result.passed[2].schema).to.equal("FAQPage"); | ||
}); | ||
}); | ||
it("apple latest newsroom article has NewsArticle and BreadcrumbList ", () => { | ||
cy.visit("https://www.apple.com/newsroom/"); | ||
cy.get("#everydayfeed > .section-content > .section-tiles") | ||
.find("li") | ||
.first() | ||
.click(); | ||
cy.location().then((location) => { | ||
cy.task("structuredData", { | ||
url: location.href, | ||
schemas: ["NewsArticle", "BreadcrumbList"], | ||
}).then((result) => { | ||
expect(result.passed.length).to.equal(2); | ||
expect(result.passed[0].schema).to.equal("NewsArticle"); | ||
expect(result.passed[1].schema).to.equal("BreadcrumbList"); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
const { structuredDataTest } = require("structured-data-testing-tool"); | ||
const { | ||
Google, | ||
Twitter, | ||
Facebook, | ||
} = require("structured-data-testing-tool/presets"); | ||
|
||
/** | ||
* @type {Cypress.PluginConfig} | ||
*/ | ||
module.exports = (on, config) => {}; | ||
module.exports = (on, config) => { | ||
on("task", { | ||
async structuredData({ url, schemas = [], presets = [] }) { | ||
const result = await structuredDataTest(url, { | ||
schemas: schemas, | ||
presets: presets, | ||
auto: false, | ||
}).catch((err) => { | ||
console.warn(err); | ||
return {}; | ||
}); | ||
return result; | ||
}, | ||
}); | ||
}; |
This file contains 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
Oops, something went wrong.