mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
feat: Record time difference in tests
This commit is contained in:
@@ -110,6 +110,14 @@ export const openURLAndVerifyRendering = (
|
||||
|
||||
cy.visit(url);
|
||||
cy.window().should('have.property', 'rendered', true);
|
||||
cy.window().then((win) => {
|
||||
cy.task('recordRenderTime', {
|
||||
fileName: Cypress.spec.name,
|
||||
testName: name,
|
||||
// @ts-ignore Dynamically added property.
|
||||
timeTaken: win.renderTime,
|
||||
});
|
||||
});
|
||||
cy.get('svg').should('be.visible');
|
||||
|
||||
if (validation) {
|
||||
|
@@ -8,6 +8,7 @@ function b64ToUtf8(str) {
|
||||
|
||||
// Adds a rendered flag to window when rendering is done, so cypress can wait for it.
|
||||
function markRendered() {
|
||||
window.renderTime = Date.now() - window.loadTime;
|
||||
if (window.Cypress) {
|
||||
window.rendered = true;
|
||||
}
|
||||
@@ -131,6 +132,7 @@ if (typeof document !== 'undefined') {
|
||||
window.addEventListener(
|
||||
'load',
|
||||
function () {
|
||||
this.window.loadTime = Date.now();
|
||||
if (this.location.href.match('xss.html')) {
|
||||
this.console.log('Using api');
|
||||
void contentLoadedApi().finally(markRendered);
|
||||
|
Reference in New Issue
Block a user