-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Emit event when all tests are done #175
Comments
I have the same problem. My use case: I have a web page which runs tape in the browser, and I have a phantomjs-script that loads that page. When the tests are done (and all results have been written), I want to exit the phantomjs process. A workaround seems be:
But +1 for a more official API. |
👍 This is my quick&dirty solution as the one @webthusiast mentioned did not work for me. https://github.com/Pajk/tape/commit/a4355d8466a0894855c470164f9f7c2e5d227af5 It's called only when all tests pass but that's enough for my case. I use it to disconnect node-postgres connection pool. |
Also interested in this feature. I tried @webthusiast's method, but the 'end' event never fires. |
Or perhaps my problem is different - there is no summary printed at the end of the tests... It looks like the tests are simply not ending. |
+1 I've decided this is now a useful feature >_>; |
@Raynos How does tape know when to emit the end event if there are async tests? Do all calls to |
At some point the program exits and prints the number of oks. Thats a good place to hook into. Have to read more code. I think it's simply reference counting. |
My asyc test just hangs indefinitely. |
I was initially encountering this issue only to discover the real culprit was my MySQL connection not closing (remained hanging) after the tests. I have yet to encounter this problem with only static or local files and processes. Figured that insight may or may not be of use to others. |
I think different people might be looking at this issue from different angles. I think the OP describes a problem which could be investigated/solved if a new feature is added (@tsironis please correct me if I'm wrong). The name of the issue also suggests it's a feature request. I think related bugs might best be put in their own issues. @Raynos: I'd like to start with writing a test, so it's probably a good start to agree on an interface. I'm thinking of making tape a promise, so that the following is possible:
Or:
Maybe an additional event/callback-based implementation would be desired later, but I don't immediately see an obvious implementation for that. Agree? Or suggestions? |
@webthusiast no promises. The cleanest thing to do is:
|
+1 on test.on('end', onEnd)` Having this hook available would probably be useful for cuke-tap, or any other module that wraps around |
The problem with that is that |
Tear down is reasonable. |
|
Let's rename to tape.onFinish(cb); |
no 🚲 🏠 here, |
@webthusiast do you want to open a pull request ? :) |
+1 |
Hi @Raynos @substack, is this pull request still on your radar? |
This is ended up being my problem also, I think. I wrapped certain test files in a promise handler and cleaned up my DB connections in the |
+1: I'm writing a custom test runner that seems to be working perfectly, except it exits before any tests are run because the tests are asynchronous. I'm writing the custom running so I can configure and maintain output formatter and output stream (and other resources) inside JS code. |
@Raynos I'm not sure this feature entirely works. Since globbing happens asynchronously, you can't guarantee the |
I'm agree with @blakeembrey, I was trying to setup an |
I've been trying to run a mock API server that I wrote and use it with tape, but it seems that when the mock API server is running,
tape
cannot exit. Although I get the usual message,the suite never really ends.
Is there a way to know when all tests are done? I've read the docs and couldn't find anything relevant.
The text was updated successfully, but these errors were encountered: