Fork me on GitHub
#re-frame
<
2018-06-06
>
rnagpal13:06:58

What is the best way to test type 2 component ?

lwhorton16:06:14

hey guys, i wanted to get some opinions on a good way to run some functional tests on a re_frame app. i already have what I would call “smoke” tests that use a webdriver api to click through a couple major components, testing a few happy paths e2e across live apis. what i’m looking for next is ui-focused tests that 1) still use a webdriver-style click-through/interaction-via-browser, but doesn’t talk to real APIs and instead only receives precanned json responses

lwhorton16:06:34

this in theory is really simple, just replace the :http cofx i have registered, and mock out a bunch of precanned responses instead of live network requests. the problem is at my implementation level … what’s a good strategy for running a testing suite from clj? the best i can come up with is pre-building the app under a different target, where this build is a copy of my “live build” except the cofx that touch apis are replaced by stubs. i really wish I could just use with-redefs [my.existing/http mock-http] but obv that doesnt work because you can’t mix clj/cljs runtimes 😞

kwladyka17:06:33

What is the best practice SPA with re-frame to see on github? I am talking about something real and bigger than todo challenge.

mikerod19:06:23

@U0WL6FA77 there are a few of these out there: * One based on the “RealWorld” spec for this sort of example problem https://github.com/polymeris/re-frame-realword-example-app * Another I’ve seen mentioned a few times before https://github.com/yogthos/memory-hole

mikerod19:06:58

I won’t speak to whether or not they are “good” or not, just that they have been used before in cases like what you’re looking for

kwladyka20:06:16

mostly I want to see code after 1-2 years of maintenance, so it needs to be real application, not example code

Bravi18:06:31

in my re-frame app I had namespaced subscriptions and events. now I’ve removed the namespaced ones and replaced with normal ones (with the same names of course. I just changed :: to :) and now none of my subscriptions and event handlers work. could there be a reason for this?

Bravi18:06:09

oh actually never mind. I don’t have them loaded in my core.cljs

Bravi18:06:14

and that’s why..

chadhs22:06:22

looking for some advice. if you’re building a simple client side re-frame app, but you need a little proxy microservice to front some api calls; is it a common pattern to make that part of the same repository? local dev would be firing up that ring app, and then also firing up a separate cljs+figwheel repl to run the front end?

bhauman22:06:56

@chadhs better to have the separate server for the application and launch it seperately from figwheel

bhauman22:06:17

the whole application, proxy and the rest of it

bhauman22:06:16

figwheel should connect to the running application when launched seperately

chadhs22:06:03

@bhauman so in my simple example I’d be better off with a repo for the proxy service and one for my client app

bhauman23:06:11

is that a question?

bhauman23:06:09

@chadhs is that a statement or a question?

bhauman23:06:58

if its a question I'd say not neccessary

chadhs23:06:50

@bhauman a question yes

bhauman23:06:20

so you are wondering how to run a seperate server?

chadhs23:06:13

So proxy server could live in project src/clj and start that separately?

bhauman23:06:50

@chadhs first do you need a proxy server or can you connect to it directly from your app?

bhauman23:06:33

second a proxy server at its simplest is just a clojure namespace that defines a ring-endpoint / middleware

chadhs23:06:49

Proxy due to CORS issue

bhauman23:06:20

@chadhs let's drill down a bit here what CORS issue specifically?

chadhs23:06:22

Yeah true so could live in same project and I start that first

bhauman23:06:48

is the service hosted elsewhere on the internets?

chadhs23:06:06

My client app is hitting open weather map api every 15 mins and works

chadhs23:06:24

Want to use dark sky but they don’t enable CORS

chadhs23:06:39

Thus the proxy

chadhs23:06:03

I’m running this locally on a raspberry pie so I wouldn’t really be leaking an API key but I understand why they don’t allow Cors

bhauman23:06:12

OK so I would use lein-ring to create a server that serves your whole application compiled cljs assets index.html and your api proxy

chadhs23:06:02

Awesome thnx will try this when back at machine !! 😎