Fork me on GitHub

With re-frame & react native, how do I render a component so I can assert on it in a doo test? In tests I’m unable to require my-project.core because it requires cljs-exponent, which requires react-native, which fails because “DEV__ is not defined”. Google says this is a babel problem, not sure how to get past this. Once I pass that hurdle, not sure how to “shallow” render the component. CRNA apps use “react-test-renderer”. Reagent has a “render” method but it renders into a DOM element. Any suggestions? Thanks to @tiensonqin & @seantempesta for lein expo(nent) templates!


I’ve been using enzyme but only to do shallow renders, I think a better solution is to use:


You’d probably want to convert your reagent components to react components using reactify-component


On a meta level I have found that component tests are less relevant when we have spec + re-frame. It’s more important for us to unit test fns that handle business logic.


With “us” I mean my colleagues and I.


Thank you for the tips! Any thoughts on how to require react-native/jest/setup in a cljs.test, to get Jest’s RN mocks? Currently getting “Unexpected token )” type errors because babel isn’t converting. I tried npm i [email protected] and setting .babelrc to {"presets": ["react-native"]} to no effect. Maybe it’s because we’re using doo?


Yeah I used babel-register to compile required files on the fly. Not very fast but ok for tests


So, do you guys do (js/JSON.stringify (clj->js {:some "map"})) before sending a payload with js/fetch or do you do something different?


And another question: Do you guys use react natives fetch or do you pull in some external library for it?


We use transit-cljs


We have written our own wrapper for HTTP


Huh, I thought transit was its own data format and doesn't use JSON over the wire.


It converts the data to json, but it’s not pretty


Right, so you need transit on the other side to receive and un-uglify the JSON?


We use js/fetch and EDN.