You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Global afterEach in e2e.js doesn't work when I run cypress headless (cypress run) but it works when I run cypress with the UI (cypress open).
However, it does work with global beforeEach
Windows 11 Enterprise, Version: 23H2, OS build: 22631.4037, Experience: Windows Feature Experience Pack 1000.22700.1027.0
Debug Logs
empty spec
cy:log i I run before every testin this file
cy:command + visit https://example.cypress.io
cy:command + get :nth-child(2) > ul > :nth-child(5)
√ first test (603ms)
cy:log i I run before every testin this file
cy:command + visit https://example.cypress.io
cy:command + get :nth-child(2) > ul > :nth-child(5)
√ second test (249ms)
Other
No response
The text was updated successfully, but these errors were encountered:
This looks to be an issue with cypress-terminal-reporter and not cypress itself. If I replace the terminal-reporter code from printing with cy.task to log in the console, it does log before each test.
cypress.config.js
const{ defineConfig }=require('cypress')module.exports=defineConfig({// setupNodeEvents can be defined in either// the e2e or component configuratione2e: {setupNodeEvents(on,config){on('task',{log(message){console.log(message)returnnull},})},},})
cypress/support/e2e/js
import"./commands";beforeEach(()=>{cy.task("log","I run before every test in this file");});afterEach(()=>{cy.task("log","I run after every test in this file");});
Current behavior
Global afterEach in e2e.js doesn't work when I run cypress headless (cypress run) but it works when I run cypress with the UI (cypress open).
However, it does work with global beforeEach
Desired behavior
Global afterEach in e2e.js works
Test code to reproduce
https://github.com/xavigimenezsanchez/cypress-cancel-request
Cypress Version
12.8.1
Node version
18.15.0
Operating System
Windows 11 Enterprise, Version: 23H2, OS build: 22631.4037, Experience: Windows Feature Experience Pack 1000.22700.1027.0
Debug Logs
Other
No response
The text was updated successfully, but these errors were encountered: