Skip to content

Commit

Permalink
complete refactor of the examples core code, not completed only README
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardogiorato committed Sep 3, 2021
1 parent 83f5133 commit 8f1ae1a
Show file tree
Hide file tree
Showing 22 changed files with 156 additions and 8 deletions.
3 changes: 3 additions & 0 deletions examples/form-inputs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# form-inputs

TODO
2 changes: 1 addition & 1 deletion cypress.json → examples/form-inputs/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"pluginsFile": false,
"reporter": "junit",
"reporterOptions": {
"mochaFile": "report/[hash].xml",
"mochaFile": "../../report/[hash].xml",
"toConsole": true
},
"retries": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe("Tesla Newsletter Form", async function () {
describe("Tesla Newsletter Form Inputs", async function () {
const test_id = new Date().getTime();
const fake_email = `fake.email.cypress4everything+${test_id}@gmail.com`;

Expand Down
12 changes: 12 additions & 0 deletions examples/form-inputs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "form-inputs",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "cypress open",
"test": "cypress run"
},
"dependencies": {
"cypress": "^8.3.1"
}
}
3 changes: 3 additions & 0 deletions examples/http-response-status/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# http-response-status

TODO
16 changes: 16 additions & 0 deletions examples/http-response-status/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fixturesFolder": false,
"supportFile": false,
"pluginsFile": false,
"reporter": "junit",
"reporterOptions": {
"mochaFile": "../../report/[hash].xml",
"toConsole": true
},
"retries": {
"runMode": 2,
"openMode": 0
},
"screenshotOnRunFailure ": false,
"experimentalStudio": true
}
File renamed without changes.
12 changes: 12 additions & 0 deletions examples/http-response-status/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "http-response-status",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "cypress open",
"test": "cypress run"
},
"dependencies": {
"cypress": "^8.3.1"
}
}
47 changes: 47 additions & 0 deletions examples/structured-data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Sitemap

## Getting the array of all the Urls from the sitemap.xml
```javascript
let urls = [];
before(() => {
cy.request({
url: "https://www.vercel.com/sitemap.xml",
headers: {
"Content-Type": "text/xml; charset=utf-8",
"user-agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36",
},
})
.as("sitemap")
.then((response) => {
urls = Cypress.$(response.body)
.find("loc")
.toArray()
.map((el) => el.innerText);
});
});
```

## Full Check

For a complete check we then need to check if the Urls are valid.

```javascript
it("should succesfully load each url in the sitemap", () => {
urls.forEach((url) => {
cy.visit(url);
});
});
```

## Fast Check

Checking a sitemap for missing pages can take a long time with cypress using cy.visit.
This is due to the fact that "cy.visit" will wait for the page javascript to have fully loaded.
If we want to check the rendered pages faster we just check for the response from the server when we ask for the page.
If the server sends us back a 200 response we continue to the next page!

## Integration Files

- [Fast Sitemap Check](cypress/integration/sitemap-fast.ts): check the sitemap fast, checks only 200 response to page urls
- [Slow Sitemap Check](cypress/integration/sitemap-slow.ts): check the complete page fully loaded
15 changes: 15 additions & 0 deletions examples/structured-data/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"fixturesFolder": false,
"supportFile": false,
"reporter": "junit",
"reporterOptions": {
"mochaFile": "../../report/[hash].xml",
"toConsole": true
},
"retries": {
"runMode": 2,
"openMode": 0
},
"screenshotOnRunFailure ": false,
"experimentalStudio": true
}
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions examples/structured-data/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "structured-data",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "cypress open",
"test": "cypress run"
},
"dependencies": {
"cypress": "^8.3.1",
"structured-data-testing-tool": "^4.5.0"
}
}
3 changes: 3 additions & 0 deletions examples/tesla/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tesla

TODO
16 changes: 16 additions & 0 deletions examples/tesla/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"fixturesFolder": false,
"supportFile": false,
"pluginsFile": false,
"reporter": "junit",
"reporterOptions": {
"mochaFile": "../../report/[hash].xml",
"toConsole": true
},
"retries": {
"runMode": 2,
"openMode": 0
},
"screenshotOnRunFailure ": false,
"experimentalStudio": true
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe("Tesla Trip", () => {
describe("Tesla Trips", () => {
const baseUrlTesla = "https://www.tesla.com/";
Cypress.on("uncaught:exception", () => {
return false;
Expand Down
12 changes: 12 additions & 0 deletions examples/tesla/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "tesla",
"private": true,
"version": "0.0.0",
"scripts": {
"dev": "cypress open",
"test": "cypress run"
},
"dependencies": {
"cypress": "^8.3.1"
}
}
5 changes: 1 addition & 4 deletions examples/url-query/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Url Query Parameters

Testing Url Query Parameters makes it possible to test the variables added in the browser URL!
This is very common in web development and with search engines result page URLs.
# Structured Data

TODO
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"dependencies": {
"junit-report-merger": "^3.0.1",
"structured-data-testing-tool": "^4.5.0",
"xml-js": "^1.6.11"
},
"workspaces": {
Expand Down

0 comments on commit 8f1ae1a

Please sign in to comment.