'How to write unit test with Jest, Fastdom and Preact

I am working on a project that uses fastdom, typescript and preact, and @testing-library/preact. But when I try to write a test, it complains that fastdom is undefined.

My question is how does the fastdom and the preact testing library work? I suppose it runs only that component I render, but it doesn't seem to the case.

here is my code

// SearchResult.test.tsx
import SearchResult from '##/components/SearchResult';

describe('Search Result', () => {
  it('should start with a blank screen', () => {
    render(<SearchResult isLoading={false} />);
    expect(screen.children.length).toEqual(0);
  });
});

Error Message: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source