archfz/cypress-terminal-report

enableExtendedCollector prevents usage of Cypress on fail event

mylmor opened this issue · 2 comments

mylmor commented

Using enableExtendedCollector in the installLogsCollector seems to prevent me from using Cypress.on('fail', (error, runnable));
I'm able to see the "LOOK AT ME" just fine if I don't enable the enableExtendedCollector in the config.

in e2e.ts

Cypress.on('fail', (error, runnable) => {
  console.log('LOOK AT ME');
  throw error; // throw error to have test still fail
});

require('cypress-terminal-report/src/installLogsCollector')({
  commandTimings: 'timestamp',
  enableExtendedCollector: true,
});
archfz commented

The plugin has the following logic:

Cypress.prependListener('fail', function (error) {

Maybe try to do prependListener after you registered the plugin.

Although I think that could ruin the plugin functionality. Maybe you could also try to not throw the error. Unfortunately I am not very up to date how that even handler works. It might be that only one listener can exists, or that only one should throw, the last one.

mylmor commented

Seems to work without breaking the lib.
Thanks !