Fork me on GitHub
#cljsrn
<
2016-08-10
>
artemyarulin07:08:33

Has anybody figured out how to run CLJS tests on emulator/device? I’m using doo as a test runner and eventually solved it with couple of my own custom tools (like https://github.com/artemyarulin/koh/blob/93cf22ea5e3d89a6a2b410741d186c000d3c3408/kohRN/kohRNTests/kohRNTests.m#L12-L30), but I do believe that nowadays there should be a better way

vikeri07:08:05

@artemyarulin: Seems testing is not really a priority at facebook. I am testing my re-frame logic and has worked with react-native-mock to test the components in node. Works alright.

vikeri07:08:25

Or at least what is available for React Native is not very impressive.

artemyarulin07:08:26

Yeah, I’m testing my own logic with Node (and Planck) nowadays. But sometimes I want to check that actual IO works, maybe some rendering tests, etc. you know.

artemyarulin07:08:12

They have something now - https://facebook.github.io/react-native/docs/testing.html#integration-tests-ios but I’m not sure that I need all this

vikeri07:08:37

@artemyarulin: Yeah I’ve thought some about testing in RN. And ultimately I figured that if my components render without a javascript error (even though I can not verify that they look aright) and my subscriptions and handlers work the way they should then I should avoid the majority of the bugs I’ve encountered so far at least. But som real integration tests would be sweet...

vikeri07:08:34

Yeah but it is amazingly poorly documented so without knowing what they are thinking its quite hard to achieve productive results...

vikeri07:08:10

I did a minimal repo with integration testing but abandoned it for now: https://github.com/vikeri/rn-integration-tests

artemyarulin07:08:13

oh that’s super cool - so does it work already? Why you’ve abandoned it?

vikeri07:08:12

What I did was just to isolate out the examples from their own repo, I couldn’t get it to do much more tricks and I’m very much a beginner in Obj-C so the effort of making it something useful overweighed the value of it (for now).

vikeri08:08:20

It’s not as easy to run xcode on CI either, so that was a minus in the usefulness as well. (Using Gitlab CI)

artemyarulin08:08:41

yep, I’ve been developing for IOS for 5 years already - and XCode with CI is a constant pain. Thank you for your repo, I’ll spend couple of hours with testing, maybe I’ll figure out some easy way

vikeri08:08:10

Yeah great! I’ll blindly merge any PR’s if you find it useful 😜

pesterhazy08:08:04

@boorad: did you try patching your react-native as explained there?

vikeri08:08:56

@pesterhazy: I’m getting this error in boot: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact mattsum:boot-react-native:jar:0.3-SNAPSHOT in clojars ()

vikeri09:08:58

nvm, just had to run example/dev in the cloned boot-react-native repo.

seantempesta09:08:52

No idea if it works with RN, but I just attended a talk on iOS testing where this guy did 2 months of research and he recommended Calabash. http://calaba.sh/

artemyarulin09:08:06

As far as I remember it’s about UI testing first of all. in RN world there is snapshot testing which is also quiet interesting https://facebook.github.io/jest/blog/2016/07/27/jest-14.html

pesterhazy09:08:52

@seantempesta, @artemyarulin: both very interesting

pesterhazy09:08:12

@vikeri: did you get it to run?

vikeri09:08:54

@pesterhazy: Not running yet, how do I add dev deps? Tried

(set-env! :dependencies #(conj % [binaryage/devtools "0.7.2"]))

vikeri09:08:02

But it didn’t work

pesterhazy09:08:49

I think there's a ' missing before the vector?

vikeri12:08:50

@pesterhazy: Following your blog post and copying the files from the example app I have now successfully transitioned from re-natal to boot-react-native 🎉 runtime error stacktraces with source maps, here I come!

pesterhazy12:08:44

note that I disabled source maps in the latest version because it slowed down things quite a bit

pesterhazy12:08:59

I'm sure there is a relatively straightforward way to put them back in

pesterhazy12:08:25

you can, however, click on the stacktrace in the red screen, and the packager will open an editor in the terminal window

pesterhazy12:08:39

that's a bit weird, but super helpful for browsing the stack traces

pesterhazy12:08:58

with optimizations none, you can read the clojurescript compiler output pretty well

vikeri12:08:57

Hmm, it would be nice to have a switch, so that I could turn sourcemaps on when I run into an error but off otherwise

artemyarulin12:08:44

is source maps really helps? I’m using optimization none during development and I’ve never actually thought about source map

vikeri12:08:29

Alright, sounds good then. Never really looked at optimizations none transpiled code.

vikeri12:08:52

I’ll try it first

pesterhazy12:08:12

I think sourcemaps are a really nice feature and we should get them back

pesterhazy12:08:28

there are two places that need to be fixed in the code

pesterhazy12:08:40

agree that it would have been better to hide the feature behind a switch

pesterhazy12:08:48

@vikeri: added your suggestion to the gh issue

vikeri13:08:09

Hmm, having problems with require not finding node modules when I’m trying to get my tests to run. Any ideas?

pesterhazy13:08:49

what's the error message?

vikeri13:08:06

Cannot find module 'react-native-mock/mock.js’

vikeri13:08:53

Before I only had (def react-native (js/require "react-native-mock”)) but I changed it to (def react-native (js/require "react-native-mock/mock.js”))

pesterhazy14:08:28

1. restart the app (not relying on boot-reload)

pesterhazy14:08:47

2. clearing the packager cache (react-native start --refresh-cache true)

vikeri14:08:45

But the packager should not even be involved. I am directly testing my js file with node

pesterhazy14:08:54

check if it properly found the require statement

vikeri14:08:18

But I would like to debug the output of the js file

pesterhazy14:08:28

hm that's a pretty unusual use case

pesterhazy14:08:52

I'd be curious if you can make that work (essentially run the output in node)

vikeri14:08:49

I did that, I required babel, mocked out react-native and then all business logic works. I even managed to sort of test my components using enzymes render function.

vikeri14:08:37

Yeah it is quite neat to be able to run it purely on node. Works well with CI and it is very fast.

pesterhazy14:08:08

so am I hearing this right that this works with the cljs compiler output?

pesterhazy14:08:18

and node replaces the rn packager?

vikeri14:08:02

The problem was that I had moved the node_modules into the directory app. I created a symlink from the root folder and then the tests worked with leiningen again.

pesterhazy14:08:30

careful with symlinks, they confuse the RN packager terribly

vikeri14:08:57

Yes, but I will never run the RN packager in the root folder right?

tianshu14:08:47

If I want to use re-natal & react-native-navigation, any additional work shoud I do besides those steps in react-native-navigation's tutorial?

tianshu14:08:03

(def Navigation (aget (js/require "react-native-navigation") "Navigation"))

(defn init-nav []
  (let [app-root (r/reactify-component app-root)]
    (.registerComponent Navigation "app-root" (fn [] app-root))
    (.startTabBasedApp Navigation
     (clj->js
      {:tabs [{:label "One"
               :title "Screen One"
               :screen "app-root"}]}))))

(defn init []
  (dispatch-sync [:initialize-db])
  (init-nav))
I modify code to this, after success react-native run-ios and lein figwheel ios, my figwheel forever waiting for connection, and there's nothing in my app.

tianshu17:08:52

I found trick for figwheel-bridge.js

tianshu17:08:17

now it works, but hot-reloading strange

boorad18:08:13

@pesterhazy: It has been patched.

boorad18:08:15

oddly, I’m seeing a temp directory for boot:

boorad18:08:27

Adding /Users/brad/.boot/cache/tmp/Users/brad/dev/clj/boot-react-native/example/1lnb/z4oa8w to fileset

boorad18:08:45

I thought that would go away if #46 isn’t in master

boorad18:08:25

most of your files in example/app/build?

pesterhazy20:08:34

Yup, in app/build

pesterhazy20:08:23

Maybe try clearing the packager cache

pesterhazy20:08:52

Otherwise you could try checking the bundle produced