Skip to content

Stale comment re vitest global: true for ESM projects #1512

@Tobbe

Description

@Tobbe

Currently for ESM projects we have this in vitest.setup.ts

  // If vitest globals are enabled testing-library will clean up after each
  // test automatically, but we don't enable globals, so we have to manually
  // clean up here
  // https://testing-library.com/docs/react-testing-library/api/#cleanup

And Greptile is complaining

Stale comment contradicts actual config

The comment says globals are not enabled, but vite.config.ts sets globals: true. With Vitest globals mode, @testing-library/react already auto-installs an afterEach cleanup, so this manual cleanup() call is redundant. The comment should be updated (or the manual call removed) to avoid confusion.

I made it global: true to make CJS -> ESM migration easier. And I want to keep it like this when I make ESM default.
Then, after ESM has been default for a while I want to switch to global: false.

But for now I should make the comment match the actual behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions