Objective: Utilize Cypress and Typescript to test for warnings and errors on the console.
Error Encounter:
An attempt was made to wrap warn, which is already wrapped
.
Snippet:
describe.only("Unauthenticated User", () => {
it("No Console Errors for /", () => {
cy.visit("/", {
onBeforeLoad(win) { cy.spy(win.console, 'error').as('onBeforeLoadSpyWinConsoleError') },
onLoad(win) { cy.spy(win.console, 'error').as('onLoadSpyWinConsoleError') }
});
cy.get('@onBeforeLoadSpyWinConsoleError').should('have.callCount', 0);
cy.get('@onLoadSpyWinConsoleError').should('have.callCount', 0);
});
it("No Console Warns for /", () => {
cy.visit("/", {
onBeforeLoad(win) { cy.spy(win.console, 'warn').as('onBeforeLoadSpyWinConsoleWarn') },
onLoad(win) { cy.spy(win.console, 'warn').as('onLoadSpyWinConsoleWarn') }
});
cy.get('@onBeforeLoadSpyWinConsoleWarn').should('have.callCount', 0);
cy.get('@onLoadSpyWinConsoleWarn').should('have.callCount', 0);
});
});
Can someone provide a solution to rectify this error as well as suggest methods to eliminate code redundancy? Additionally, any recommended resources for further understanding of this issue would be greatly appreciated.