is there some work planned around <https://youtrac...
# react
p
is there some work planned around [KT-49610] KJS: Allow unit-testing React components ? I pretty much like using Kotlin/JS + React, but no ability to test the components is a major disadvantage when trying to convince my colleagues to actually use it wider in the company
CC @Ilya Kalibrov [JB] since I see you’re assigned there
r
I can’t comment on official support, but having been testing kotlin react components over the last few years I can add my 2 cents if you like on getting the ball rolling with the current available tools
p
yes, it would be really cool! could you prepare a trivial example, like unit-testing a single-property component?
r
I’ll see if I can find one in an open-source project :) at this time, it involves a kotlin wrapper around common testing-library functions, and taking advantage of returning promises from kotlin tests
Here’s a pretty simple one (arguably too simple, as it doesn’t actually require awaiting any promises!) https://github.com/robertfmurdock/Coupling/blob/master/client/src/test/kotlin/com/zegreatrob/coupling/client/stats/PlayerHeatmapBuilderTest.kt
(also doesn’t use the testing library query functions… which it should. Haha they’re in that codebase somewhere, I should refactor this!)
p
thanks! I see mainly this wrapper over `@testing-library/react`: https://github.com/robertfmurdock/Coupling/blob/55d6925d752fee1bd4af2ce8d1dc32b8ff[…]ob/coupling/testreact/external/testinglibrary/react/External.kt BTW, I like the structure (
asyncSetup
,
exercise
,
verify
)! interesting project: https://github.com/robertfmurdock/testmints
r
thank you 🙂
p
reminds me of https://spockframework.org/ anyway, back to React testing, it would be super-cool if you could gather more advanced examples, and even if you don’t, I’m going to do it as part of my project within the next 1-2 months
r
there are some littered throughout that project - i remember i was going through the process of converting enzyme tests to react testing library tests but i’m not sure if i finished or not.