Skip to content

Add global cleanup #13

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

Closed
marquesm91 opened this issue Mar 18, 2019 · 1 comment · Fixed by #16
Closed

Add global cleanup #13

marquesm91 opened this issue Mar 18, 2019 · 1 comment · Fixed by #16
Labels
enhancement New feature or request

Comments

@marquesm91
Copy link
Contributor

marquesm91 commented Mar 18, 2019

I love react-testing-library and would be interesting if react-hooks-testing-library have the same clean up behavior.

So besides this

import { cleanup } from 'react-hooks-testing-library';

afterEach(cleanup);

We could have one more way to do that and use the same approach as react-testing-library and use it in setup files

import 'react-hooks-testing-library/cleanup';
// or
import 'react-hooks-testing-library/cleanup-after-each';

The implementation could be the same as react-testing-library

// cleanup-after-each.js or just cleanup.js
afterEach(require('./dist').cleanup);

// to make sense to react-hooks-testing-library just change to /lib
afterEach(require('./lib').cleanup);

So the test suites would be more cleaner and you don't have to worry about cleanups. I would love to open a PR for this. 😁

@marquesm91 marquesm91 added the enhancement New feature or request label Mar 18, 2019
@marquesm91 marquesm91 changed the title Add clean-up-after-each Add global cleanup Mar 18, 2019
@mpeyper
Copy link
Member

mpeyper commented Mar 19, 2019

I would love to open a PR for this. 😁

Well, don't let me stand in your way. Just make sure you add yourself as a contributor before you're done.

For consistency, I'd go with cleanup-after-each.js.

marquesm91 added a commit to marquesm91/react-hooks-testing-library that referenced this issue Mar 19, 2019
@marquesm91 marquesm91 mentioned this issue Mar 19, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants