DouglasNeuroInformatics / libui

Generic UI components for DNP projects, built using React and TailwindCSS
https://douglasneuroinformatics.github.io/libui/
Apache License 2.0
2 stars 2 forks source link

test: fix issue where form tests fail on low powered hardware #28

Closed joshunrau closed 4 months ago

joshunrau commented 4 months ago

When submitting the form in unit tests, the data validation is performed asynchronously. Therefore, in tests the flow of execution (after submit, checking conditions) continues without awaiting for the validation to complete, after which the onSubmit mock callback is invoked. The result of the test can therefore vary depending on the performance of the machine they are run on (on my machine, for example, this was not evident because the validation completed before the condition was checked).

This is fixed by using the waitFor function as documented here.