Created
December 4, 2021 17:36
-
-
Save Ebazhanov/428852f2df9a7a39f3a3a9966c520126 to your computer and use it in GitHub Desktop.
print & spy logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import item1 from '../fixtures/example-1-item-1.json' | |
it('Should show functioning log & copy buttons', () => { | |
cy.visit('/', { | |
onBeforeLoad(win) { | |
cy.stub(win.console, 'log').as('consoleLog') | |
cy.stub(win.console, 'info').as('consoleInfo') | |
cy.stub(win.console, 'error').as('consoleError') | |
cy.stub(win.navigator.clipboard, 'writeText').as('write') | |
} | |
}) | |
cy.get('#showLogButton').click() | |
cy.get('#showCopyButton').click() | |
cy.get('.log-copy-button').should('have.length', 468) | |
cy.get('.log-copy-button').eq(1).click() | |
cy.get('@write').should('be.calledWith', JSON.stringify(item1)) | |
cy.get('.log-copy-button').eq(0).click() | |
cy.get('@consoleInfo').should( | |
'be.calledWith', | |
'%c [svelte-tree-view]: Property added to window._node' | |
) | |
cy.get('@consoleLog').should('be.calledWith', item1) | |
cy.get('@consoleError').should('be.callCount', 0) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment