cypress-fail-on-console-error icon indicating copy to clipboard operation
cypress-fail-on-console-error copied to clipboard

Does not property listen to log events in component runner

Open davidturissini opened this issue 2 years ago • 1 comments

Inside of https://github.com/nils-hoyer/cypress-fail-on-console-error/blob/main/src/index.ts#L16, cypress-fail-on-console-error is listening to window:before:load events, which do not get called in component mode.

Repro: Add the following to support.ts in a component runner:

import failOnConsoleError rom "cypress-fail-on-console-error"

failOnConsoleError();

Create this test:

it('should fail', () => {
  console.error('fail');
})

Expected: test fail Actual: test succeeds

davidturissini avatar Apr 11 '22 23:04 davidturissini

Hi @davidturissini, thanks for reporting that issue. Afaik the cypress component runner was in Alpha state in cypress version < 10 and just hit Beta state starting from version 10. I would like to wait until a release version exists before diving into that feature request but feel free to provide a PR or fork the repo.

nils-hoyer avatar Jun 07 '22 21:06 nils-hoyer

Hello @nils-hoyer, appreciate your work on this plugin. I just tried to use it for a component test that was passing even when there was a console errror, but found the plugin not working and then found this issue.

Cypress component testing is out of beta https://www.cypress.io/blog/2022/11/08/announcing-cypress-11/, any chance you could look into this issue?

klofi avatar Mar 07 '23 21:03 klofi

Linked PR: https://github.com/nils-hoyer/cypress-fail-on-console-error/pull/219

nils-hoyer avatar Aug 03 '23 12:08 nils-hoyer

The PR is merged and support for component testing mode is released with version 5.0.0.

Thanks to @jimmux!

nils-hoyer avatar Aug 08 '23 09:08 nils-hoyer

Thank you very much, I can confirm the cypress component tests now fail on console error with v5.0.0.

klofi avatar Aug 15 '23 14:08 klofi