I'm writing a mocha test reporter that I want to use for customized Cypress tests documentation. Which is the right way to debug reporter code (maybe with intellij Idea)?
EDIT I tried to debug using intellij Idea tools, running cypress (both open and run) in debug mode. I also tried the IntelliJ Cypress plugin pro version that allow test debugging.
I can't stop in breakpoints.
So I'm trying at least to print some debug log but I can't see my logs anywere.
I couldn't make it work with Cypress, but I could do with Mocha in VSCode.
Working example here
Steps to debug:
Install ts-node and typescript for your project:
npm i ts-node typescript --save-devCreate custom-reporter.ts in your
srcfolder with this content: (taken from https://mochajs.org/api/tutorial-custom-reporter.html and modified slightly )index.jsas follows and we export our reporter as follows:package.jsonif you want to run without debugging:.vscode/launch.jsonin your project root, and add the following code:Place some breakpoints in VSCode into src/custom-reporter.ts
In VSCode open the
Run and Debugpanel (Ctrl+Shift+D), selectDebug Mocha testsand press the play buttonThis way you should be able to start the test running and hit your breakpoints in VSCode.
Cheers!