lambdaisland / kaocha-cljs

ClojureScript support for Kaocha
Eclipse Public License 1.0
40 stars 10 forks source link

How to run tests that contain npm dependencies installed using shadow? #31

Closed zendevil closed 4 years ago

zendevil commented 4 years ago

I try running a test on this cljs file like so:

(use 'kaocha.runner)
(run 'vendo.workspaces.cards_test) ;; cljs file

But I get the following error:

Caused by: clojure.lang.ExceptionInfo: No such namespace: @testing-library/react, could not locate _CIRCA_testing_library_SLASH_react.cljs, _CIRCA_testing_library_SLASH_react.cljc, or JavaScript source providing "@testing-library/react" (Please check that namespaces with dashes use underscores in the ClojureScript file name) in file /Users...

I installed the @testing-library/react library through npm. How do I run kaocha tests then that include npm dependencies?

plexus commented 4 years ago

Shadow-cljs is unfortunately not supported at the moment.

Duplicate of #2

ghost commented 3 years ago

@zendevil ran into a similar issue -- in my test.edn I did this to get around this warning when running tests and provide the needed libs

:cljs/compiler-options {:foreign-libs [{:file "https://cdnjs.cloudflare.com/ajax/libs/ant-design-icons/4.2.2/index.umd.min.js"
                                      :provides  ["@ant-design/icons"]}
                                     {:file "https://cdnjs.cloudflare.com/ajax/libs/antd/4.7.2/antd.compact.min.css"
                                      :provides ["antd"]}]}}
ghost commented 3 years ago

Requiring cljsjs libs also works in the :test alias of your deps file if they're available