Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
engineerchirag committed Jan 10, 2024
2 parents 7e853d9 + 4715367 commit dd7c905
Show file tree
Hide file tree
Showing 6 changed files with 7,832 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@
- Server-side JavaScript Injection (SSJI)
- Feature Policy | Permissions-Policy
- Subresource Integrity (SRI)
- Cross-Origin Resource Sharing (CORS)
- Cross-Origin Resource Sharing (CORS)


# Testing
- Unit Testing & Integration Testing
- Component Testing
- Jest & JS DOM
- Testing Library / React Testing Library
- Automation Testing
- e2e Test cases
- Tools - Puppeteer , Cypress, Selenium

27 changes: 27 additions & 0 deletions testing/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const users = [
{
name: "Simran",
age: 30,
},
{
name: "Akshay",
age: 28,
},
{
name: "Sachin",
age: 50,
},
{
name: "Elon",
age: 8,
},
];

function sortingByAge() {
const data = users.sort((a, b) => a.age - b.age);
return data;
}

console.log(sortingByAge());

module.exports = sortingByAge;
13 changes: 13 additions & 0 deletions testing/app.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const sortingByAge = require("./app");

test("testing if the first user is Elon after sorting", () => {
const sortedData = sortingByAge();

expect(sortedData[0].name).toBe("Elon");
});

test("testing if the sorted data has length of 4", () => {
const sortedData = sortingByAge();

expect(sortedData).toHaveLength(4);
});
39 changes: 39 additions & 0 deletions testing/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const puppeteer = require("puppeteer");

(async () => {
const browser = await puppeteer.launch({
headless: false,
slowMo: 100,
args: ["--window-size=1920,1080"],
});

const page = await browser.newPage();

await page.goto("https://amazon.com");

console.log("Webpage Loaded");

await page.setViewport({ width: 1620, height: 1080 });

const coursesPageLink = ".menu > li:nth-child(3) > a";

await page.waitForSelector(coursesPageLink);

await page.click(coursesPageLink);

console.log("Courses Page Loaded");

const enrollButton = ".bg-success-btn";
await page.waitForSelector(enrollButton);

await page.click(enrollButton);

console.log("Namaste FSD page loaded");

// await browser.close();
})();

// HomeWork:
// Automate whole user journey
// Run this sript everyday at 08:00 AM - CRON job
// Collect all the logs and erorrs send it to email - Amazon SES
Loading

0 comments on commit dd7c905

Please sign in to comment.