Skip to content

Add global cleanup #13

Closed
Closed
@marquesm91

Description

@marquesm91

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. 😁

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions