Replies: 2 comments 2 replies
-
@remy90 you might have some useful tips to share on this topic? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Open to any input, but so far I'm experimenting with simply mocking the returned functions from const useEmblaCarousel = jest.spyOn(emblaCarouselReact, 'default');
const emblaApi: emblaCarouselReact.UseEmblaCarouselType[1] = {
canScrollNext: jest.fn(),
canScrollPrev: jest.fn(),
containerNode: jest.fn(),
internalEngine: jest.fn(),
destroy: jest.fn(),
off: jest.fn(),
on: jest.fn(),
emit: jest.fn(),
plugins: jest.fn(),
previousScrollSnap: jest.fn(),
reInit: jest.fn(),
rootNode: jest.fn(),
scrollNext: jest.fn(),
scrollPrev: jest.fn(),
scrollProgress: jest.fn(),
scrollSnapList: jest.fn(),
scrollTo: jest.fn(),
selectedScrollSnap: jest.fn(),
slideNodes: jest.fn(),
slidesInView: jest.fn(),
slidesNotInView: jest.fn(),
};
useEmblaCarousel.mockImplementation(() => {
const emblaRef = useRef();
return [
emblaRef,
emblaApi,
] as unknown as emblaCarouselReact.UseEmblaCarouselType;
}); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey! I've recently been using Embla as the backbone for a Carousel component, and now it's time to add some tests. My company uses Jest and react-testing-library if that helps. Curious if anyone else has had any luck writing tests for carousels built with Embla, and what was your approach? I'll probably end up doing some mocking.
Beta Was this translation helpful? Give feedback.
All reactions