Vitest is a nodejs testing framework from the Vite project which is commonly used for testing NextJS applications.
NextJS provide a walkthrough for setting up Vitest here.
Checking Elements are in the DOM
In your test file add:
And then in the test itself you can add the expectation:
Mocking fetch requests
If you are testing functions that make calls to the fetch() command you can mock it globally. You will probably also need to give it a mocked return value to prevent the call returning null which breaks promise chains in the target function.