-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 is not getting called when the test process is interrupted by hitting Ctrl + C #516
Comments
hmmm in general -1 but what's the cleanup doing that is so crucial? i know it doesnt fit every case but i usually clean out the db in a before / beforeEach etc so even failures are fine |
actually i almost never use after / afterEach |
well, we are seeding the database only once in the |
gotcha, why not add another |
¯(°_o)/¯ |
hahaha that's sweet |
my specs were looking so natural until a hit this wall. I can use |
IMO it just makes more sense than trying to recover from every possible fail point, im not 100% against it if it was an option but it's sort of a non-problem, I agree though that most people will be doing it this way and that it feels more natural |
I'm going to implement |
hahaha, nah I totally get it, just thinking on it. we need some more people in here that use after hooks, because im not totally convinced that they should exist |
you know they exist in every single respetable BDD/TDD/xUnit framework, that's why you designed it like that in mocha. It just needs a small tweak heheh |
yup, doesn't mean they really make sense though. A test can fail in so many different ways, if the machine shuts down you have bad state, if you get SIGKILL you have bad state etc |
indeed, but those are exceptional situations, hitting Ctrl + C to terminate the runner in development time is fairly common. |
yeah i thing SIGINT is reasonable |
hahahahaha. ill try it in a min |
so it does work fine, but I think this will have edge-cases regardless, if you SIGINT during one of the after hooks then you're fucked anyway |
hm, I was expecting it to call |
that part works fine, but if what's hanging is an after hook then you're screwed |
or if you just happen to SIGINT at the wrong time |
agreed, it minimizes the chance to screw things up anyway. Do you feel like pushing that into master or you're not entirely sure yet? |
From my experience the most common scenario is the test hanging for some reason, the |
im not feelin it so far, mostly because then we are kind of promising something that isn't really possible, the only thing you could do is flat-out ignore SIGINT when after hooks are being fired, but then if you are really hanging you'll have to kill(1) it which is not any more convenient |
fair enough, let's leave it open for now until we clear things up a bit more. I wonder how other test frameworks deal with this though. |
yup it's still something to consider |
Issue has been inactive for years, and I feel @tj was completely right in his doubt about adding the feature. Closing for now, happy to re-open if someone feels like this is still a problem. |
If looks like this issue still exist in mocha 6. |
I'm launching docker containers inside Being able to jump into |
@visionmedia what do you think about catching SIGTERM, SIGINT and SIGHUP, running the
after
callback function to clean things up in the test?The text was updated successfully, but these errors were encountered: