Skip to content

Lots of new act warnings since 9.3.1 #1251

Closed
@jgarplind

Description

@jgarplind
  • @testing-library/dom version: 9.3.1
  • Testing Framework and version: vitest 0.33/0.34.2
  • DOM Environment: jsdom 22.1.0

Relevant code or config:

  it("should group items", async () => {
    renderWithReactQueryAndReactRouter();

    const user = userEvent.setup();
    await user.selectOptions(
      await screen.findByRole("combobox", { name: "group" }),
      ["property"],
    );
    expect(
      screen.getByRole("columnheader", { name: "John Doe" }),
    ).toBeInTheDocument();
  });

What you did:

Re-installed packages for the first time since @testing-library/dom@9.3.1 was released, triggering an upgrade since I use @testing-library/user-event which has a peer dependency: "@testing-library/dom": ">=7.21.4"

This is the different in my pnpm-lock.yaml:

  /@testing-library/dom@9.3.0:
    resolution: {integrity: sha512-Dffe68pGwI6WlLRYR2I0piIkyole9cSBH5jGQKCGMRpHW5RHCqAUaqc2Kv0tUyd4dU4DLPKhJIjyKOnjv4tuUw==}
    engines: {node: '>=14'}
    dependencies:
      '@babel/code-frame': 7.21.4
      '@babel/runtime': 7.22.3
      '@types/aria-query': 5.0.1
      aria-query: 5.1.3
      chalk: 4.1.2
      dom-accessibility-api: 0.5.16
      lz-string: 1.5.0
      pretty-format: 27.5.1

  /@testing-library/dom@9.3.1:
    resolution: {integrity: sha512-0DGPd9AR3+iDTjGoMpxIkAsUihHZ3Ai6CneU6bRRrffXMgzCdlNk43jTrD2/5LT6CBb3MWTP8v510JzYtahD2w==}
    engines: {node: '>=14'}
    dependencies:
      '@babel/code-frame': 7.22.10
      '@babel/runtime': 7.22.10
      '@types/aria-query': 5.0.1
      aria-query: 5.1.3
      chalk: 4.1.2
      dom-accessibility-api: 0.5.16
      lz-string: 1.5.0
      pretty-format: 27.5.1

What happened:

New behaviors, including errors and warnings.

In particular, a lot of new act warnings:

When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state /
});
/
assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
at stacktrace pointing to component

It is really quite pervasive, and could be due to user error, but I am a fairly experience testing library user and have never seen anything like this.

Reproduction:

Seeking to understand if I am being reasonable or barking up the wrong tree before spending time on that, sorry.

Problem description:

Our trust in our tests is significantly reduced since the warnings indicate that they don't operate correctly.

Suggested solution:

Help me understand how 9.3.1, really only pinning aria-query to a slightly older version, could cause all this trouble?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions