bhauman / figwheel-main

Figwheel Main provides tooling for developing ClojureScript applications
https://figwheel.org
Eclipse Public License 1.0
640 stars 93 forks source link

Browser auto-testing doesn't work with webpack bundle #291

Closed warrenronsiek closed 3 years ago

warrenronsiek commented 3 years ago

I've noticed that when I use webpack bundling, the auto-testing in the browser doesn't happen. E.g. with the configuration

^{:extra-main-files {:testing {:main tiptip-app.test-runner}}}
{:main            tiptip_app.core
 :source-paths    ["cljs-src"]
 :foreign-libs    [{:file           "./resources/dev/js/aws-sdk-2.828.0.js"
                    :provides       ["aws-sdk"]
                    :global-exports {aws-sdk AWS}}]
 :target          :bundle
 :bundle-cmd {:none ["npx" "webpack" "--mode=development" "./target/public/cljs-out/dev/main.js"
                     "--output-path" "./target/public/cljs-out/dev"
                     "--output-filename" "main_bundle.js"]}
 :closure-defines {tiptip-app.conf/env "dev"}}

And an index.html that targets the main_bundle.js The tests don't load. Its like like the tests don't get noticed. http://localhost:9500/figwheel-extra-main/testing yeilds the boilerplate Extra Main: Testing Host Page with no tests. But when I remove the bundling:

^{:extra-main-files {:testing {:main tiptip-app.test-runner}}}
{:main            tiptip_app.core
 :source-paths    ["cljs-src"]
 :foreign-libs    [{:file           "./resources/dev/js/aws-sdk-2.828.0.js"
                    :provides       ["aws-sdk"]
                    :global-exports {aws-sdk AWS}}]
; :target          :bundle
;:bundle-cmd {:none ["npx" "webpack" "--mode=development" "./target/public/cljs-out/dev/main.js"
;                    "--output-path" "./target/public/cljs-out/dev"
;                    "--output-filename" "main_bundle.js"]}
 :closure-defines {tiptip-app.conf/env "dev"}}

This renders the testing page correctly and the tests run.

Now maybe this has something to do with the strings that I am manually passing here instead of keywords. Well, there is a reason for that, the keywords mentioned here result in schema validation errors:

Configuration error in CLJS compile options: dev.cljs.edn
-- Spec failed --------------------

  {:main ...,
   :source-paths ...,
   :foreign-libs ...,
   :target ...,
   :bundle-cmd
   {:none [... ... ... ... ... :final-output-dir ... ...]},
                               ^^^^^^^^^^^^^^^^^
   :closure-defines ...}

should satisfy

  non-blank-string?
warrenronsiek commented 3 years ago

Upgraded versions and now have different problems. Closing this as its no longer relevant.