📝 Disallow the use of cleanup.
💼 This rule is enabled in the following configs:
react,
svelte,
vue.
cleanup is performed automatically if the testing framework you're using supports the afterEach global (like mocha, Jest, and Jasmine). In this case, it's unnecessary to do manual cleanups after each test unless you skip the auto-cleanup with environment variables such as RTL_SKIP_AUTO_CLEANUP for React.
This rule disallows the import/use of cleanup in your test files. It fires if you import cleanup from one of these libraries:
- Marko Testing Library
- Preact Testing Library
- React Testing Library
- Svelte Testing Library
- Vue Testing Library
Examples of incorrect code for this rule:
import { cleanup } from '@testing-library/react';
const { cleanup } = require('@testing-library/react');
import utils from '@testing-library/react';
afterEach(() => utils.cleanup());
const utils = require('@testing-library/react');
afterEach(utils.cleanup);Examples of correct code for this rule:
import { cleanup } from 'any-other-library';
const utils = require('any-other-library');
utils.cleanup();