bensu / doo

doo is a library and lein plugin to run cljs.test on different js environments.
Eclipse Public License 1.0
324 stars 63 forks source link

Is it possible to include a JS file in a script element in doo-index.html #100

Closed jgregors closed 8 years ago

jgregors commented 8 years ago

I am writing a clojurescript app which contains a "settings.js" file for all my third party configuration etc. This file is created by a script in a build pipeline for test/prod etc and is created locally for development. I serve this file from resources/public on the web server and it is include within a element on index.html and works fine.

I am trying to run tests with doo but after going through the source I can not see a way to have added to doo-index.html and hence, gain access to the js variables in the test context. Is there a way to do this?

Any suggestions would be much appreciated.

bensu commented 8 years ago

Hi @jgregors

Can you look at #25 and see if it solves your problem? If so, I'll find a way to properly document it.

jgregors commented 8 years ago

I saw #25 yesterdau and it seems like this would be the right solution but I have tried it and cannot get it working. My settings.js file looks like this:

var CONFIG = { SETTINGS : { AUTH0 : { CLIENT_ID : "", DOMAIN : ""}, } } }

the cljsbuild config:

` {:id "test"
                    :source-paths ["src/cljs" "test/cljs"]
                    :compiler {:output-to "resources/public/js/compiled/test.js"
                                    :main platform-ui.runner
                                    :source-map-timestamp true
                                    :foreign-libs [{:file "resources/public/js/settings.js"
                                                         :provides ["CONFIG"]}]}}`

After adding this the "settings.js" file is not referenced in the doo-index.html and I get "ReferenceError: Can't find variable: CONFIG"

This doesn't look like a doo problem but if you can spot what I am messing up it and suggestions would be a big help.

jgregors commented 8 years ago

I can get a passing test for including jquery as per your example so I am doing something wrong in regards to the namespacing for what I need. I will work it out. Thanks for getting back to me.

bensu commented 8 years ago

No problem, if you can't figure out just ping me back here with an example repo and we'll take it from there even if it's not doo related.

jgregors commented 8 years ago

Thanks, Sebastian. I have it working now and it is fine for what I need. The example repo in #25 is good for showcasing how to do this and I did see this before raising this issue - I just couldn't work out what I was messing up. Do you think it's worth documenting? If so, let me know if you want me to create a PR.

bensu commented 8 years ago

I do think it is worth documenting, many people want to add special files for testing. A short wiki article should be enough. Let me know if you have an OS project we could use an example.

jgregors commented 8 years ago

Sorry for the slow reply Sebastian. I don't have something OS at the moment but can easily put together something. That said, I think that your example/repo in #25 is very clear.

On 4 April 2016 at 23:22, Sebastian Bensusan notifications@github.com wrote:

I do think it is worth documenting, many people want to add special files for testing. A short wiki article should be enough. Let me know if you have an OS project we could use an example.

— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/bensu/doo/issues/100#issuecomment-205294498

bensu commented 8 years ago

Thanks @jgregors, then I'll look into adding something with that repo.