Issue with testing components that use slots
I don't seem to be able to use the fireEvent method to trigger a change while using a component that has slots?
I've made an example in this repo, you can clone it and run yarn test to see, but essentially the fireEvent doesn't seem to bubble up the change to the parent component when the child component is using a slot?
https://github.com/PClmnt/svelte-testing-library-issue
I'm thinking this may be more of a nuance of carbon-components-svelte than of svelte-testing-library. After looking at issues in the carbon components repo it seems like the suggested use, in this case, is to add the event handler to the slot component. See this comment as an example. Indeed if I follow the pattern suggested there and change your example to:
<script>
import { Button } from 'carbon-components-svelte'
let loggedIn = 'yes'
function changeState() {
loggedIn = 'no'
}
</script>
<section>
<div>
{#if loggedIn === 'yes'}
<Button as kind="secondary">
<span on:click={() => changeState()}>test</span>
</Button>
{:else if loggedIn === 'no'}
<div>example text</div>
{/if}
</div>
</section>
The test now passes

@yanick I agree with @jgbowser's assessment, this definitely looks like a fundamental limitation/problem with carbon-components-svelte. There's nothing unique to svelte-testing-library here, I think this issue should be closed
I agree with the agreement. Closing. :-)