Git Product home page Git Product logo

Comments (1)

layershifter avatar layershifter commented on August 15, 2024

TL;DR Toast and other components use new motion APIs that rely on WAAPI that is not supported by jsdom (jsdom/jsdom#3429) (jsdom is an env Jest).


I made a previous week PR that improves compat of our internal polyfilling (#31602). And similar tests are passing:

act(() => {
userEvent.click(getByText('Click me'));
});
expect(queryByText('Hello')).not.toBeInTheDocument();

So, I was extremely confused on why this happens 🐱 This looks to be a compat issue with @testing-library/userevent or React, the sandbox uses version @testing-library/user-event@14 & React 18 while we are using @testing-library/user-event@13 & React 17.

I have built a minimal repro using React 18 (https://stackblitz.com/edit/acntkb-sru9mp) and it seems that React became more async in tests.

The solution seems to use requestAnimationFrame() there:

if (process.env.NODE_ENV === 'test') {
if (animations.length === 0) {
callback();
return;
}
}

It indeed fixes an issue for React 18, but breaks for React 17... 💥

from fluentui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.