Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Core node modules work in app but not in tests #148

Open
eccentric-j opened this issue Feb 4, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@eccentric-j
Copy link

commented Feb 4, 2019

PROBLEM:

I am able to access core node modules in dev build but not in my tests.

REPRODUCTION:

Created https://github.com/eccentric-j/minirepro-fig-test-deps to minimally reproduce the problem

  1. Run git clone git@github.com:eccentric-j/minirepro-fig-test-deps.git
  2. Run cd minirepro-fig-test-deps
  3. Run lein fig:build
  4. Run node target/node/dev/dev-main.js
  5. You should see output similar to:
    Loaded main script
    Running main fn
    #js [".gitignore" "README.md" "dev.cljs.edn" "figwheel-main.edn" "node_modules" "package-lock.json" "package.json" "project.clj" "src" "target" "test" "test.cljs.edn"]
    
  6. It worked. Now run lein fig:test

EXPECTED:

  • Tests pass or fail
  • Exit code should reflect test status

ACTUAL:

  • Tests never run
  • Error is thrown:
    No such namespace: fs, could not locate fs.cljs, fs.cljc, or JavaScript source providing "fs" in file minirepro-fig-test-deps/src/minirepro_fig_test_deps/core.cljs {:tag :cljs/analysis-error}
        at cljs.analyzer$error.invokeStatic(analyzer.cljc:706)
        at cljs.analyzer$error.invoke(analyzer.cljc:702)
        at cljs.analyzer$error.invokeStatic(analyzer.cljc:704)
        at cljs.analyzer$error.invoke(analyzer.cljc:702)
        at cljs.analyzer$analyze_deps.invokeStatic(analyzer.cljc:2159)
        at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:2133)
        at cljs.analyzer$ns_side_effects.invokeStatic(analyzer.cljc:3509)
        at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:3504)
        at cljs.analyzer$analyze_STAR_$fn__2534.invoke(analyzer.cljc:3629)
        at clojure.lang.PersistentVector.reduce(PersistentVector.java:343)
        at clojure.core$reduce.invokeStatic(core.clj:6827)
        at clojure.core$reduce.invoke(core.clj:6810)
        at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:3629)
        at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:3619)
        at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:3649)
        at cljs.analyzer$analyze.invoke(analyzer.cljc:3631)
        at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1390)
        at cljs.compiler$emit_source.invoke(compiler.cljc:1369)
        at cljs.compiler$compile_file_STAR_$fn__3696.invoke(compiler.cljc:1471)
        at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1289)
        at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1278)
        at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1455)
        at cljs.compiler$compile_file_STAR_.invoke(compiler.cljc:1448)
        at cljs.compiler$compile_file$fn__3727.invoke(compiler.cljc:1553)
        ... 74 more

Questions:

  • Am I importing core node modules incorrectly?
  • Why does it work with npm deps but not built-in node modules?
  • If the answer is simple, should I make a PR to update the docs?

Environment:

dev.cljs.edn:

^{:watch-dirs ["test" "src"]
  :auto-testing true}
{:main minirepro-fig-test-deps.core
 :npm-deps     {"ws" "6.1.3"}
 :install-deps true
 :target :nodejs}

test.cljs.edn

^{
  ;; use an alternative landing page for the tests so that we don't
  ;; launch the application
  :open-url "http://[[server-hostname]]:[[server-port]]/test.html"

  ;; uncomment to launch tests in a headless environment
  ;; you will have to figure out the path to chrome on your system
  ;; :launch-js ["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" "--headless" "--disable-gpu" "--repl" :open-url]
  }
{:main minirepro-fig-test-deps.test-runner
 :target :nodejs}
@bhauman

This comment has been minimized.

Copy link
Owner

commented Apr 10, 2019

Yes your test.cljs.edn file is not correct.

You at least need to remove the :open-url param as it makes no sense in this context. I think the :open-url is causing this to run in the Browser and thats why you are getting that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.