Async suite clean up

55 views
Skip to first unread message

Evan Worley

unread,
Jun 3, 2013, 6:29:32 PM6/3/13
to casp...@googlegroups.com
Hello,

What is the best way to do some  asynchronous clean up after a test suite is done running? For example, during the run some resources are created and I'd like to delete them when done with the run. I've discovered the casper exit event, but this does not seem to wait for async events to complete.

Thanks,
Evan

Evan Worley

unread,
Jun 12, 2013, 5:38:05 PM6/12/13
to casp...@googlegroups.com
Any thoughts on this would be greatly appreciated.

Nicolas Perriault

unread,
Jun 13, 2013, 1:34:39 AM6/13/13
to casp...@googlegroups.com
On Wed, Jun 12, 2013 at 11:38 PM, Evan Worley <ev...@dnanexus.com> wrote:

>> What is the best way to do some asynchronous clean up after a test suite
>> is done running?
> Any thoughts on this would be greatly appreciated.

The tester has a `tests.complete` event triggered when a suite is finished:

casper.test.on('test.complete', function() {
// perform cleanup
});

You could also describe cleanup operations in a js file you pass to
the --post option:

$ casperjs test --post=cleanup.js

++

--
Nicolas Perriault
https://nicolas.perriault.net/
Phone: +33 (0) 660 92 08 67

Evan Worley

unread,
Jun 13, 2013, 2:57:21 AM6/13/13
to casp...@googlegroups.com
Hi Nicholas,

I tried the test.complete handler, but the problem is that my // perform cleanup function is asynchronous and the process does not wait until it's done. Any ideas on how to handle async clean up logic?

Thanks,
Evan


--
CasperJS homepage & documentation: http://casperjs.org/
CasperJS @github: https://github.com/n1k0/casperjs

You received this message because you are subscribed to the Google Groups "casperjs" group.
Visit this group at http://groups.google.com/group/casperjs?hl=en.
---
You received this message because you are subscribed to a topic in the Google Groups "CasperJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/casperjs/shCvos8F990/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to casperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




---
The contents of this e-mail and any attachments are confidential and only for use by the intended recipient. Any unauthorized use, distribution or copying of this message is strictly prohibited. If you are not the intended recipient please inform the sender immediately by reply e-mail and delete this message from your system. Thank you for your co-operation.

Nicolas Perriault

unread,
Jun 13, 2013, 9:57:45 AM6/13/13
to casp...@googlegroups.com
On Thu, Jun 13, 2013 at 8:57 AM, Evan Worley <ev...@dnanexus.com> wrote:

> I tried the test.complete handler, but the problem is that my // perform
> cleanup function is asynchronous and the process does not wait until it's
> done. Any ideas on how to handle async clean up logic?

Did you try the --post=post.js trick? you could add a last async test
to perform your cleanup here

Evan Worley

unread,
Jun 13, 2013, 1:44:18 PM6/13/13
to casp...@googlegroups.com
I haven't tried it, but will try it today! I assume this runs regardless of if a test earlier in the suite failed? Right now I'm injecting a test named "zzzz_cleanup" to do the cleanup, but it only runs if there were no failures.

--
CasperJS homepage & documentation: http://casperjs.org/
CasperJS @github: https://github.com/n1k0/casperjs

You received this message because you are subscribed to the Google Groups "casperjs" group.
Visit this group at http://groups.google.com/group/casperjs?hl=en.
---
You received this message because you are subscribed to a topic in the Google Groups "CasperJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/casperjs/shCvos8F990/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to casperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages