Repository: mermaid-js/mermaid
File: cypress/integration/other/configuration.spec.js (JavaScript)

Code before:
      cy.get('.edgePaths').within(() => {
        cy.get('path')
          .first()
          .should('have.attr', 'marker-end')
          .should('exist')
          .and('include', 'url(http://localhost');
      });
    });
    it('should not taint the initial configuration when using multiple directives', () => {
      const url = 'http://localhost:9000/regression/issue-1874.html';
      cy.viewport(1440, 1024);
      cy.visit(url);

      cy.get('svg');
      cy.matchImageSnapshot(
        'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives'
      );
    });
  });

  describe('suppressErrorRendering', () => {
    it('should not render error diagram if suppressErrorRendering is set', () => {
      const url = 'http://localhost:9000/suppressError.html?suppressErrorRendering=true';
      cy.viewport(1440, 1024);
      cy.visit(url);
      cy.get('#test');
      cy.matchImageSnapshot(
        'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set'
      );
    });

    it('should render error diagram if suppressErrorRendering is not set', () => {
      const url = 'http://localhost:9000/suppressError.html';
      cy.viewport(1440, 1024);
      cy.visit(url);
      cy.get('#test');
      cy.matchImageSnapshot(
        'configuration.spec-should-render-error-diagram-if-suppressErrorRendering-is-not-set'
      );
    });
  });
});


Review comment (bug):
I'm getting a race-condition when running the E2E test. The following seems to fix it:

```suggestion
      cy.get('#test').find("svg").should(($svg) => {
        expect($svg).to.have.length(2); // all failing diagrams should not appear!
        $svg.each((_index, svg) => {
          expect(cy.$$(svg)).to.be.visible;

          // none of the diagrams should be error diagrams
          expect($svg).to.not.contain("Syntax error");
        });
      });
```

### See screenshot of before and after:

![configuration spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set diff](https://github.com/mermaid-js/mermaid/assets/19716675/61d57753-6e8e-4f78-b056-7d0aa30f2690)


Code after:
      cy.get('.edgePaths').within(() => {
        cy.get('path')
          .first()
          .should('have.attr', 'marker-end')
          .should('exist')
          .and('include', 'url(http://localhost');
      });
    });
    it('should not taint the initial configuration when using multiple directives', () => {
      const url = 'http://localhost:9000/regression/issue-1874.html';
      cy.visit(url);

      cy.get('svg');
      cy.matchImageSnapshot(
        'configuration.spec-should-not-taint-initial-configuration-when-using-multiple-directives'
      );
    });
  });

  describe('suppressErrorRendering', () => {
    beforeEach(() => {
      cy.on('uncaught:exception', (err, runnable) => {
        return !err.message.includes('Parse error on line');
      });
    });

    it('should not render error diagram if suppressErrorRendering is set', () => {
      const url = 'http://localhost:9000/suppressError.html?suppressErrorRendering=true';
      cy.visit(url);
      cy.window().should('have.property', 'rendered', true);
      cy.get('#test')
        .find('svg')
        .should(($svg) => {
          // all failing diagrams should not appear!
          expect($svg).to.have.length(2);
          // none of the diagrams should be error diagrams
          expect($svg).to.not.contain('Syntax error');
        });
      cy.matchImageSnapshot(
        'configuration.spec-should-not-render-error-diagram-if-suppressErrorRendering-is-set'
      );
    });

    it('should render error diagram if suppressErrorRendering is not set', () => {
      const url = 'http://localhost:9000/suppressError.html';
      cy.visit(url);
      cy.window().should('have.property', 'rendered', true);
      cy.get('#test')
        .find('svg')
        .should(($svg) => {
          // all five diagrams should be rendered