felte
felte copied to clipboard
Q: Felte loading done event?
I'm running some end to end tests using playwright on my svelte app using felte for my forms.
Sometimes my tests run so fast, that they click the form's submit button before felte finishes initialising, so it tries to submit it like a native form, which obviously fails.
Is there some wait to wait until felte is done? Is there some event emitted or anything I can use to make sure this doesn't happen?
Check for a store https://felte.dev/docs/svelte/stores
@drewbitt so say look at the presence of a field in $data? Like $data.myField !== undefined would let me know that felte has finished initialising and I can continue my test?
Okay, so this seems to work:
$: felteLoaded = Object.keys($data).length > 0 || undefined
<form data-felte-loaded={felteLoaded} use:form>
/** ... **/
</form>
Then I can just use a selector to wait for the form to have the data-felte-loaded attribute. Thanks @drewbitt