Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress does report beforeEach and afterEach hooks errors only afterEach error #24712

Open
jjkavalam opened this issue Nov 17, 2022 · 2 comments
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: unexpected behavior User expected result, but got another

Comments

@jjkavalam
Copy link

jjkavalam commented Nov 17, 2022

Current behavior

Following test (cypress/e2e/spec.cy.js) throws 2 errors. Both are reported in the console output. But the dashboard only reports one of them. Please see the linked repo for screenshots and logs.

Desired behavior

All errors should be reported in the dashboard.

Test code to reproduce

https://github.com/jjkavalam/cypress-bug-report-1

Cypress Version

11.1.0

Node version

v14.14.0

Operating System

macOS 12.3.1

Other

No response

@marktnoonan marktnoonan self-assigned this Nov 17, 2022
@marktnoonan
Copy link
Contributor

I've been able to reproduce this with the example code thanks @jjkavalam. The Dashboard is reporting what is logged by the command log in the App. In the App, an error in a beforeEach shows up, and if there is an error in an afterEach, the afterEach shows up instead.

If we do intend to show just one error message - we should show the beforeEach, but since both blocks executed, it seems correct to show both errors in the log.

@marktnoonan marktnoonan removed their assignment Nov 17, 2022
@emilyrohrbough emilyrohrbough changed the title Cypress dashboard does not report all the errors Cypress does report beforeEach and afterEach hooks errors only afterEach error Apr 12, 2023
@emilyrohrbough emilyrohrbough added type: unexpected behavior User expected result, but got another DX labels Apr 12, 2023
@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. and removed routed-to-e2e labels Apr 19, 2023
@jennifer-shehane jennifer-shehane added type: user experience Improvements needed for UX and removed DX type: user experience Improvements needed for UX labels Oct 4, 2023
@alecmestroni
Copy link

Same problem here, if a test fails and then the after/afterEach also fails the report will only pass the last error.
There is no way to retrieve the main error of the test even within the hooks of test:after:run, its like its been overwritten by the last error:
describe('mocha behavior with multiple errors', function () { beforeEach(function () { throw new Error('error 1') }) it('sample test', function () { throw new Error('error 3') }) afterEach( function () { throw new Error('error 2') }) });
So only the last error will be passed to the reporter and there is no way to recover the main test error nowhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

6 participants