From b902297935b13ad11e763cef6bc02ab4c649e7c4 Mon Sep 17 00:00:00 2001 From: Zachary Williams Date: Fri, 9 Sep 2022 15:53:45 -0500 Subject: [PATCH] fix: default mount log to true --- npm/svelte/src/mount.ts | 2 +- .../project-fixtures/svelte/src/mount.cy.js | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/npm/svelte/src/mount.ts b/npm/svelte/src/mount.ts index b90581f895d0..3fad1ac21274 100644 --- a/npm/svelte/src/mount.ts +++ b/npm/svelte/src/mount.ts @@ -76,7 +76,7 @@ export function mount ( // by waiting, we are delaying test execution for the next tick of event loop // and letting hooks and component lifecycle methods to execute mount return cy.wait(0, { log: false }).then(() => { - if (options.log) { + if (options.log !== false) { const mountMessage = `<${getComponentDisplayName(Component)} ... />` Cypress.log({ diff --git a/system-tests/project-fixtures/svelte/src/mount.cy.js b/system-tests/project-fixtures/svelte/src/mount.cy.js index 998006e0c3c8..d5e004820438 100644 --- a/system-tests/project-fixtures/svelte/src/mount.cy.js +++ b/system-tests/project-fixtures/svelte/src/mount.cy.js @@ -53,4 +53,34 @@ describe("Svelte mount", () => { cy.then(() => messageStore.set("Written from spec")); cy.contains("h1", "Written from spec"); }); + + context("log", () => { + it("displays component name in mount log", () => { + cy.mount(Counter); + + cy.wrap(Cypress.$(window.top.document.body)).within(() => + cy + .contains("displays component name in mount log") + .closest(".collapsible") + .click() + .within(() => + cy + .get(".command-name-mount") + .should("contain", "mount") + ) + ); + }); + + it("does not display mount log", () => { + cy.mount(Counter, { log: false }); + + cy.wrap(Cypress.$(window.top.document.body)).within(() => + cy + .contains("does not display mount log") + .closest(".collapsible") + .click() + .within(() => cy.get(".command-name-mount").should("not.exist")) + ); + }); + }); });