Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goToPrev isn't working in unit test environment #154

Open
cannahum opened this issue Oct 30, 2023 · 0 comments
Open

goToPrev isn't working in unit test environment #154

cannahum opened this issue Oct 30, 2023 · 0 comments

Comments

@cannahum
Copy link

cannahum commented Oct 30, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant