Skip to content

goToPrev isn't working in unit test environment #154

@cannahum

Description

@cannahum

I have a control button that triggers the following:

function handlePrevClick() {
	if (currentPageIndex > 0) {
		carousel.goToPrev();
	}
}

I'm also tracking changes this way:

function handlePageChange(e: CustomEvent<number>) {
	currentPageIndex = e.detail;
}
<Carousel
	arrows={false}
	bind:this={carousel}
	dots={false}
	infinite={false}
	on:pageChange={handlePageChange}
	swiping={false}
>
</Carousel

The issue happens when handlePrevClick is called via a button click. It's working well in browser: I can debug the handlePrevClick and handlePageChange are both called; however, when I run unit tests (testing-library/svelte), even though I can see that handlePrevClick is called, handlePageChange isn't called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions