From 56cc12690f4369eea69d76182e510b1523ecb540 Mon Sep 17 00:00:00 2001 From: saurabhg772244 Date: Fri, 5 Sep 2025 12:47:07 +0530 Subject: [PATCH] Added option to skip screenshot for cypress tests --- cypress/helpers/util.ts | 7 +++++-- cypress/integration/rendering/flowchart-handDrawn.spec.js | 2 +- cypress/integration/rendering/flowchart.spec.js | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cypress/helpers/util.ts b/cypress/helpers/util.ts index 81b7036af..79be26dd9 100644 --- a/cypress/helpers/util.ts +++ b/cypress/helpers/util.ts @@ -6,6 +6,7 @@ interface CypressConfig { listUrl?: boolean; listId?: string; name?: string; + screenshot?: boolean; } type CypressMermaidConfig = MermaidConfig & CypressConfig; @@ -92,7 +93,7 @@ export const renderGraph = ( export const openURLAndVerifyRendering = ( url: string, - options: CypressMermaidConfig, + { screenshot = true, ...options }: CypressMermaidConfig, validation?: any ): void => { const name: string = (options.name ?? cy.state('runnable').fullTitle()).replace(/\s+/g, '-'); @@ -105,7 +106,9 @@ export const openURLAndVerifyRendering = ( cy.get('svg').should(validation); } - verifyScreenshot(name); + if (screenshot) { + verifyScreenshot(name); + } }; export const verifyScreenshot = (name: string): void => { diff --git a/cypress/integration/rendering/flowchart-handDrawn.spec.js b/cypress/integration/rendering/flowchart-handDrawn.spec.js index e5a188a7b..d3ca1d1f1 100644 --- a/cypress/integration/rendering/flowchart-handDrawn.spec.js +++ b/cypress/integration/rendering/flowchart-handDrawn.spec.js @@ -1039,7 +1039,7 @@ graph TD style C stroke-width:4px,stroke-dasharray: 5 L_A_B_0@{ animation: slow } L_B_D_0@{ animation: fast }`, - { look: 'handDrawn' } + { look: 'handDrawn', screenshot: false } ); cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow'); cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast'); diff --git a/cypress/integration/rendering/flowchart.spec.js b/cypress/integration/rendering/flowchart.spec.js index 6a655096b..8e4adb30d 100644 --- a/cypress/integration/rendering/flowchart.spec.js +++ b/cypress/integration/rendering/flowchart.spec.js @@ -775,13 +775,16 @@ describe('Graph', () => { }); }); it('40: should add edge animation', () => { - renderGraph(` + renderGraph( + ` flowchart TD A(["Start"]) L_A_B_0@--> B{"Decision"} B --> C["Option A"] & D["Option B"] style C stroke-width:4px,stroke-dasharray: 5 L_A_B_0@{ animation: slow } - L_B_D_0@{ animation: fast }`); + L_B_D_0@{ animation: fast }`, + { screenshot: false } + ); // Verify animation classes are applied to both edges cy.get('path#L_A_B_0').should('have.class', 'edge-animation-slow'); cy.get('path#L_B_D_0').should('have.class', 'edge-animation-fast');