Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"eslint.validate": [
"javascript",
"javascriptreact",
"node"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.formatOnSave": true
}

"eslint.validate": ["javascript", "javascriptreact", "node"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.formatOnSave": true
}
75 changes: 47 additions & 28 deletions cypress/e2e/2-advanced-examples/game.cy.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
describe('Game Interaction', () => {
beforeEach(() => {
cy.visit('/');
describe("Game Interaction", () => {
beforeEach(() => {
cy.visit("/");
});

it("Should enter the correct password and start the game", () => {
cy.get("#passwordInput").type("password"); // replace 'your_password' with your actual password
cy.get("button").click();
cy.get("#gameContainer").should("exist");
});

it("Should lose the game", () => {
cy.get("#passwordInput").type("wrong_password");
cy.get("button").click();
cy.on("window:alert", (str) => {
expect(str).to.equal("Incorrect password!");
});

it('Should enter the correct password and start the game', () => {
cy.get('#passwordInput').type('password'); // replace 'your_password' with your actual password
cy.get('button').click();
cy.get('#gameContainer').should('exist');
});

it("Should shoot projectiles", () => {
cy.get("#passwordInput").type("password");
cy.get("button").click();

// Assuming you have a shooting mechanism that involves mouse clicks
// You should adjust the coordinates based on your game mechanics
cy.get("#canvas1").click(400, 400); // Replace with your actual coordinates
});

describe("Score Calculation", () => {
it("Score points through various actions and verify accuracy", () => {
let initialScore;
cy.get("#scoreElement") // Replace with the actual identifier of the score element.
.invoke("text")
.then((score) => {
initialScore = parseInt(score, 10);
});

// Step 3: Capture the final score.
let finalScore;
cy.get("#scoreElement") // Replace with the actual identifier of the score element.
.invoke("text")
.then((score) => {
finalScore = parseInt(score, 10);
});

expect(finalScore).to.be.greaterThan(initialScore);
});

it('Should lose the game', () => {
cy.get('#passwordInput').type('wrong_password');
cy.get('button').click();
cy.on('window:alert', (str) => {
expect(str).to.equal('Incorrect password!');
});
});

it('Should shoot projectiles', () => {
cy.get('#passwordInput').type('password');
cy.get('button').click();

// Assuming you have a shooting mechanism that involves mouse clicks
// You should adjust the coordinates based on your game mechanics
cy.get('#canvas1').click(400, 400); // Replace with your actual coordinates
});

// Add more test cases as needed
});
});
});