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

after:run isn't triggered when closing the project after cypress open #17532

Closed
TheDutchCoder opened this issue Jul 29, 2021 · 19 comments
Closed
Labels
type: duplicate This issue or pull request already exists

Comments

@TheDutchCoder
Copy link

Current behavior

It looks like after:run never triggers.

module.exports = async (on: any, config: { env: { awsConfig: any } }) => {
  // AWS config
  config.env.awsConfig = awsconfig

  on('after:run', () => {
    console.log('cleaning')
    clean()
  })
}

I'm not sure how it's supposed to function, the docs say it should trigger after closing the project (after cypress open), but it doesn't do that.

Maybe these docs are incomplete? It also looks like there's at least a typo here: "You can return a promise from the after:run event handler and it will be awaited before Cypress proceeds running your specs." (I'm sure that means to say after?)

Desired behavior

This trigger to be called.

Test code to reproduce

See my above piece of code.

Cypress Version

8.0.0

Other

No response

@jennifer-shehane
Copy link
Member

@TheDutchCoder How are you closing the project via cypress open?

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jul 30, 2021
@TheDutchCoder
Copy link
Author

@TheDutchCoder How are you closing the project via cypress open?

I just close the window. I don't think there's another way?

@robert-elles
Copy link

I have the same problem. after:run event is not run when you are using the test runner tool. When you are finished running tests you will close the tool window. At that point I expect cypress to trigger the after:run event.

@robert-elles
Copy link

@jennifer-shehane I think the information has been provided

@robert-elles
Copy link

This links to issue #18955

@TheDutchCoder
Copy link
Author

Is there a reason this issue still is in this state?
I've seen a newer opened issue is the same issue and confirmed.

It is still a real problem, as our DB/user seeds don't get cleaned up currently because of it, making writing tests incredibly hard.

@TheDutchCoder
Copy link
Author

I guess this is where this functionality is triggered: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/project-base.ts#L343

Since none of this is try/catched, I think something throws and it never hits the hook at the end?

It's probably a good idea to do a try/catch/finally with the hook running in the finally clause?

@dexcell
Copy link

dexcell commented Mar 3, 2022

same issue here!

@cypress-bot cypress-bot bot added stage: backlog and removed stage: needs information Not enough info to reproduce the issue labels Apr 29, 2022
@alexniculae
Copy link

Did anybody find a workaround for this until the issue is addressed and fixed?

@Alm0g
Copy link

Alm0g commented Dec 21, 2022

Any news regarding this issue?

@xavbourdeau
Copy link

Same issue here. Any workaround ?

@sutapaGanguly
Copy link

Setting experimentalInteractiveRunEvents flag to true is also not triggering the after:run.

Tried closing the browser but no luck with the same. after:spec works fine. There is issue with after:run IMO.

@patrickcate
Copy link

Ran into this as well. It is causing issues with data cleanup.

@funador
Copy link

funador commented Apr 1, 2023

Same as everyone else, want to tear some data down post-run but can't :/ If anyone has a workaround, please post it up 🙏

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Sep 29, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2023
@matthiasreinartz
Copy link

Did anybody find a workaround? This bug still seems to exist even in the latest Cypress version

@lilywang153
Copy link

same issue here with the latest Cypress version

@jennifer-shehane
Copy link
Member

Duplicate of #18955

@jennifer-shehane jennifer-shehane marked this as a duplicate of #18955 Jan 25, 2024
@jennifer-shehane jennifer-shehane added type: duplicate This issue or pull request already exists and removed stale no activity on this issue for a long period labels Jan 25, 2024
@cypress-io cypress-io locked and limited conversation to collaborators Jan 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests