testing-library / jest-dom

:owl: Custom jest matchers to test the state of the DOM
https://testing-library.com/docs/ecosystem-jest-dom
MIT License
4.44k stars 401 forks source link

Tailwind css group-hover:visible dosn't work properly #510

Open kajurek opened 1 year ago

kajurek commented 1 year ago

Following the example from tailwindcss: https://tailwindcss.com/docs/hover-focus-and-other-states#differentiating-nested-groups. Item that should be invisible is still visible.

just to be sure the config of the tailwind is ok I followed https://stackoverflow.com/questions/71010317/react-testing-library-cant-read-styles-using-tailwind-css-classes

"jsdom": "22.1.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "14.0.0", "tailwindcss": "^3.3.3",

Relevant code or config:

  it.only('example', () => {
    render(
      <div>
        <div data-testid="root" className="group/item">
          <div data-testid="test1" className="invisible group-hover/item:visible">
            test
          </div>
        </div>
      </div>,
    );

    let el = screen.getByTestId('root');
    expect(el).toBeVisible();
    expect(screen.getByTestId('test1')).not.toBeVisible();
  });

it gives:

Error: expect(element).not.toBeVisible()
Received element is visible:
  <div
  class="invisible group-hover/item:visible"
  data-testid="test1"
/>
MNeverOff commented 1 month ago

I am surprised this didn't gather more attention or replies by now, ran into the exact same issue running jsdom with vitest. @kajurek have you been able to work around this, and have you tried posting it in https://github.com/jsdom/jsdom/issues?