Please note that @testing-library/user-event version 14 has made all APIs async and the workshop material has been updated to use the latest version of that package. So you'll need to make all tests async and use await when using that package.
Kent C. Dodds: 0:00 There's one other thing that we probably should consider when we're doing this integration test. Remember this integration test grabs the app. The app is going to grab and set up a whole bunch of the other things that we're doing within our codebase.
0:13 Which, ultimately, is going to result in grabbing this Profiler module, which kicks off an interval of every five seconds to send a profile of all of the information about our rendering of our components and everything just for a performance monitoring and production.
0:29 I don't want this interval to happen over time. I'd rather not have an interval, not have the client request for the profile in any of my tests. This isn't really a critical piece of my application, so I'm feeling pretty OK with just mocking this thing out, and not having it do all of this extra work.
0:49 I already have set up for us a profilerMock in the directory right next to where this particular component lives. We have componentsProfiler, and here it's componentsMocksProfiler.
1:01 All of this is doing is it creates a Profiler component, which takes children and just returns the children. It's, basically, an empty component, and then it exports that Profiler. We export everything that this module exports. It is a legit mock.
1:18 Now all we have to is make sure that every test is mocking that. We never set that up. I'm going to add a jest.mock right here for componentsProfiler. This will make it so that any time somebody tries to render a Profiler they're going to render this one instead of this one.
1:37 It means that we'll never import this module, so we'll never set this interval to start sending the Profiler queue every five seconds. With that, let's just make sure this is going to work out, and voilà, our test continued to pass, and we don't have to worry about setting that interval or rendering that Profiler component.