felte icon indicating copy to clipboard operation
felte copied to clipboard

Q: Felte loading done event?

Open half2me opened this issue 2 years ago • 3 comments

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?

half2me avatar Jan 17 '23 16:01 half2me

Check for a store https://felte.dev/docs/svelte/stores

drewbitt avatar Jan 23 '23 05:01 drewbitt

@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?

half2me avatar Jan 23 '23 14:01 half2me

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

half2me avatar Jan 23 '23 14:01 half2me