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

Is there a way to execute an action when all tests are done? #185

Closed
remko opened this issue Aug 29, 2015 · 1 comment
Closed

Is there a way to execute an action when all tests are done? #185

remko opened this issue Aug 29, 2015 · 1 comment

Comments

@remko
Copy link

remko commented Aug 29, 2015

I'd like to call some cleanup action when all tests are finished. What is the recommended way to do this?
E.g. something like:

setup();

test("Some test", function (t) { ... t.end(); });
test("Some other test", function (t) { ... t.end(); });

test.on("end", function () { cleanup(); });

I tried on('end') and on('done') but that didn't work. It seems to work on the return value from test(), so I guess a workaround would be to wrap all tests in another test, but I'd like to avoid another level.

@ghost
Copy link

ghost commented Sep 11, 2015

If you put a test() at the end it can be used for cleanup:

test('setup', function (t) { t.end() })
test('test 1', function (t) { t.end() })
test('test 2', function (t) { t.end() })
test('teardown', function (t) { t.end() })

@ghost ghost closed this as completed Sep 11, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant