Created
March 9, 2020 15:49
-
-
Save filiphric/fcd1aa541a85cd0c5c70929b10b58403 to your computer and use it in GitHub Desktop.
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
beforeEach( function() { | |
window.logCalls = 1; | |
window.testFlow = []; | |
}); | |
Cypress.Commands.overwrite('log', (originalFn, message) => { | |
Cypress.log({ | |
displayName: `--- ${window.logCalls}. ${message} ---`, | |
name: `--- ${window.logCalls}. ${message} ---`, | |
message: '' | |
}); | |
window.testFlow.push(`${window.logCalls}. ${message}`); | |
window.logCalls++; | |
}); | |
Cypress.on('fail', (error) => { | |
throw new Error(error + '\n\nTest flow:\n' + window.testFlow.join('\n')); | |
}); |
Nice! 👍
It looks like this is working in Typescript as well. But for some reason "logCalls" and "testFlow" are getting highlighted for not existing property for window. Any recommended solution how to avoid highlighting?
I have found it is feasible to use "any" command but it is a bit dirty according to feedback.
I added these to my support/index.js as well:
declare global {
interface Window {
logCalls: number;
testFlow: string[];
}
}
Perfect! Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
take a look at cypress-io/cypress#2134 (comment)