react-testing-library icon indicating copy to clipboard operation
react-testing-library copied to clipboard

cleanup warnings are fired even if cleanup is fired manually

Open cloud-walker opened this issue 3 years ago • 2 comments

  • @testing-library/react version: 14.1
  • Testing Framework and version: Vitest 0.34
  • DOM Environment: jsdom

The v14.1 introduced a warning (#1244 ), that is yelling on my vitest based tests (notice that both warnings are fired):

image

I know about the cleanup thing and I use it manually as said by the docs, and I don't expect this warning to appear.

I've also tried the "STL_SKIP_AUTO_CLEANUP" envvar (typo in the docs, it should be RLT_), but it seems to not work, and feels weird to have to add an envvar to mute a warning

cloud-walker avatar Nov 17 '23 09:11 cloud-walker

Same, here using vitest with a setupFiles: "./tests/setup.ts" entry where I call cleanup manually:

import { afterEach } from "vitest";
import { cleanup } from "@testing-library/react";
import "@testing-library/jest-dom/vitest";

// runs a cleanup after each test case (e.g. clearing jsdom)
afterEach(() => {
    cleanup();
});

Yet I get spammed with the above messages, which is wrong as I manually call cleanup. It's only if I disable the setupFiles entry that my tests are failing (which is expected as my cleanup is not called any more).

tmkn avatar Nov 17 '23 14:11 tmkn

This change will be reverted in an upcoming patch release :)

MatanBobi avatar Nov 17 '23 15:11 MatanBobi