Fork me on GitHub
#cljsrn
<
2019-03-28
>
manu11:03:45

How to add unit test to re-natal project? thx

vikeri11:03:34

@manu We test our code using node and shimming out the RN specific parts

vikeri11:03:03

@souenzzo For re-frame it seems to work well. But if not then maybe add local state to the component?

manu11:03:28

@vikeri can you explain better?

manu11:03:42

do you mean cljs.test?

vikeri11:03:09

You can use any test framework in theory

vikeri11:03:52

If you have your business code perfectly isolated then you can just run the tests in node as ususal. But if you require in RN like we do you might have to mock out things.

manu11:03:29

at the moment I want just to add simple unit test

manu11:03:44

but I don't know how to setup my project

manu11:03:05

can you suggest a link?

manu11:03:02

now I have just a test folder with a core_test.clj file

manu11:03:25

and a failure test written inside

manu11:03:52

but if I run lein test i got errors

manu11:03:32

so I want to know how to find the right configuration

vikeri11:03:44

I know @plexus has been doing very good things on testing with his kaocha lib. So he is probably better to help you out, maybe in the #kaocha channel. Our testing setup is 3 years old and a bit of a frankestein, so while it works for us I can’t really recommend others to try it 😛

manu12:03:14

ahahaha ok 😁

pez12:03:17

If you are using shadow-cljs, @manu, then you configure the test runner like so: https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test

joshmiller18:03:49

@souenzzo If you’re seeing lag on a TextInput, don’t set the :value to an atom. If you need an initial value, use :default-value @some-atom

souenzzo18:03:16

some-atom will be a regular cljs atom? I will try

souenzzo18:03:18

Now it's less slow.

joshmiller19:03:27

The atom bit is just because people generally use a reagent atom to store state for their text-inputs. You can put a straight string in there for a default value if you want as well.

joshmiller21:03:54

I wrote a quick blog post on that quick keyboard lag issue, since it seems to come up a lot: https://increasinglyfunctional.com/2019/03/28/why-clojurescript-react-native-text-input-slow.html

parrot 4
ferossgp09:03:56

The bad part is that sometimes you want dynamically change the address in the input, for example when you press a marker on the map you want to have the address in the search. There is a lot of workarounds, but anyway it is sad.

👍 4