Skip to content

Commit

Permalink
Flaky tests (#423)
Browse files Browse the repository at this point in the history
* fix flaky tests

* fix any keyword
  • Loading branch information
Rllyyy authored Dec 21, 2024
1 parent e42a88c commit b818033
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export default defineConfig({
});
},
baseUrl: "http://localhost:3000",
defaultBrowser: "chrome",
},

component: {
defaultBrowser: "chrome",
devServer: {
framework: "react",
bundler: "vite",
Expand Down Expand Up @@ -40,9 +42,7 @@ export default defineConfig({
},
});

// Fuck cypress and their slow ass adoptation

function deleteFolder(folderName) {
function deleteFolder(folderName: string) {
return new Promise((resolve, reject) => {
if (existsSync(folderName)) {
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/QuestionEditor/QuestionEditor.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe("QuestionEditor.cy.js", () => {
cy.contains("Please select a Question Type").should("not.exist");
});

it("should grow the textarea", { scrollBehavior: false, viewportHeight: 500, viewportWidth: 480 }, () => {
it("should grow the textarea", { scrollBehavior: false, viewportHeight: 500, viewportWidth: 480, retries: 5 }, () => {
cy.get("textarea[name='title']")
.type("The title for this question should wrap to the next line", { delay: 1 })
.invoke("outerHeight")
Expand Down
5 changes: 2 additions & 3 deletions src/components/QuestionList/QuestionList.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("QuestionList", () => {
});

describe("QuestionList - Drag and Drop", { viewportWidth: 780 }, () => {
it("should move a question", () => {
it("should move a question", { retries: 5 }, () => {
cy.fixtureToLocalStorage("repeatio-module-cypress_1.json");
cy.mount(<QuestionListWithRouter moduleID='cypress_1' />);

Expand All @@ -59,6 +59,7 @@ describe("QuestionList - Drag and Drop", { viewportWidth: 780 }, () => {
.realMouseDown({ button: "left", position: "center" })
.realMouseMove(0, 150, { position: "center" })
.realMouseUp({ position: "center" })
.wait(500)
.then(() => {
cy.get("span[cy-data='id']").should(($spans) => {
const idValues = $spans.toArray().map((span) => span.textContent);
Expand All @@ -67,9 +68,7 @@ describe("QuestionList - Drag and Drop", { viewportWidth: 780 }, () => {
});

// Assert that the third question was the first question

cy.get("div[cy-data='question']").eq(2).find("span[cy-data='id']").should("have.text", "qID-1");
cy.wait(500);
});

it("should update the localStorage after drag'n'drop", () => {
Expand Down

0 comments on commit b818033

Please sign in to comment.