Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 1.68 KB

no-manual-cleanup.md

File metadata and controls

41 lines (27 loc) · 1.68 KB

Disallow the use of cleanup (testing-library/no-manual-cleanup)

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.

Rule Details

This rule disallows the import/use of cleanup in your test files. It fires if you import cleanup from one of these libraries:

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();

Further Reading