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

Running tests in figwheel's CLJS repl #1268

Closed
lvh opened this issue Aug 19, 2015 · 25 comments
Closed

Running tests in figwheel's CLJS repl #1268

lvh opened this issue Aug 19, 2015 · 25 comments

Comments

@lvh
Copy link

lvh commented Aug 19, 2015

I have some cljs.test tests. I'm connected to the REPL ran by figwheel, and have run (use 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl) to get a cljs repl. Compiling and evaling CLJS works fine, but CIDER's test functionality appears to be confused. cider-test-run-tests (C-c ,) claims it can't find the relevant namespace:

Testing...
No tests namespace: crunch.ctk-test

... when run from either crunch.ctk or crunch.ctk-test, even though I can run/eval stuff in there just fine.

@mikavilpas
Copy link

I have a clojurescript / clojurec project that uses cljs.test too, but it works for me. I set up my tests with reader conditionals to make them portable both to clojure and clojurescript. Perhaps you could work around the issue that way, if your tests are portable.

@mikavilpas
Copy link

What does your project.clj look like? It's possible it cannot find the tests due to misconfiguration.

@lvh
Copy link
Author

lvh commented Aug 25, 2015

Unfortunately, my tests are not meaningfully portable. They rely heavy on the DOM. The code I'm writing is a GreaseMonkey userscript, so differences between implementations (different browsers or maybe a JVM implementation somewhere) are important.

Here's my project.clj:

(defproject crunch "0.1.0-SNAPSHOT"
  :description "A workout for your CORE"
  :url "https://github.com/lvh/crunch"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.7.0"]
                 [org.clojure/clojurescript "1.7.107" :scope "provided"]

                 ;; Fancy pattern matching & logic programming
                 [org.clojure/core.match "0.3.0-alpha4"]
                 [org.clojure/core.logic "0.8.10"]

                 ;; React
                 [cljsjs/react "0.13.3-1"]
                 [reagent "0.5.0"]
                 [reagent-forms "0.5.6"]
                 [reagent-utils "0.1.5"]

                 ;; Bootstrap tricks
                 [wilson "0.9.0"]

                 ;; DOM tricks
                 [prismatic/dommy "1.1.0"]
                 [hickory "0.5.4"]

                 ;; Time
                 [com.andrewmcveigh/cljs-time "0.3.11"]

                 ;; Debugging and logging
                 [com.taoensso/timbre "4.1.1"]]
  :source-paths ["test" "src"]
  :target-path "target/%s"
  :clean-targets ^{:protect false} [:target-path "out" "resources/public/cljs"]
  :cljsbuild {:builds {:app {:source-paths ["src" "test"]
                             :figwheel true
                             :compiler
                             {:main "crunch.core"
                              :asset-path "cljs/out"
                              :output-to "resources/public/cljs/main.js"
                              :output-dir "resources/public/cljs/out"}}
                       :test {:source-paths ["src"  "test"]
                              :main "crunch.runner"
                              :compiler {:output-to "target/test.js"
                                         :optimizations :whitespace
                                         :pretty-print true}}}}

  :profiles
  {:dev-common
   ;; (use 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl)
   {:dependencies [;; Client side building
                   [figwheel "0.3.7"]
                   [cljsbuild "1.1.0"]

                   [org.clojure/tools.nrepl "0.2.10"]

                   ;; Client side testing
                   [doo "0.1.4"]
                   [org.clojure/core.async "0.1.346.0-17112a-alpha"]]
    :plugins [[lein-figwheel "0.3.7"]
              [lein-cljsbuild "1.1.0"]
              [lein-doo "0.1.4"]
              [lein-cljfmt "0.2.1"]]
    :figwheel {:css-dirs ["resources/public/css"]
               :nrepl-port 7002}
    :env {:dev true}}
   :dev-overrides {};; Set this in profiles.clj
   :dev [:dev-common :dev-overrides]})

@Malabarba
Copy link
Member

Unfortunately, my tests are not meaningfully portable.

From what you've described of the problem, it sounds like the content of the tests is probably irrelevant.
The problem is more likely related to how your directories/namespaces/src-paths are structured.

@lvh
Copy link
Author

lvh commented Oct 7, 2015

Sorry; I somehow missed that you gave a suggestion of finding the issue:

  1. The test structure was previously test/cljs/* and test/clj/*. I've merged these into one, but didn't resolve the issue:
└── test
    └── shrieker
        ├── vendor
        │   └── api_test.cljs
        ├── celery_test.clj
        ├── core_test.cljs
        ├── deployment_test.clj
        ├── dom_test.cljs
        ├── handler_test.clj
        ├── home_test.cljs
        ├── insight_test.cljs
        ├── provisioning_test.cljs
        ├── rms_test.clj
        ├── runner.cljs
        ├── test_macros.clj
        └── utils_test.cljs

The namespaces are appropriate for that sturcture, e.g. myproj.utils-test.

@sp3ctum Are you using figwheel's REPL? I think this might have something to do with it...

@mikavilpas
Copy link

mikavilpas commented Oct 8, 2015 via email

@expez
Copy link
Member

expez commented Nov 26, 2015

Closing this as it doesn't seem like there's anything for the CIDER team to do here. Feel free to re-open if that isn't the case.

@expez expez closed this as completed Nov 26, 2015
@lvh
Copy link
Author

lvh commented Nov 27, 2015

How could I make this actionable? Would a public repo and reproduction steps (that show the problem for me) help?

@expez
Copy link
Member

expez commented Nov 27, 2015

@lvh yes, that would be great

@lvh
Copy link
Author

lvh commented Nov 29, 2015

OK, steps that reproduce for me:

  • Clone https://github.com/racksec/reason
  • If you have PhantomJS, you can observe that the tests run by running lein doo phantom test once, or you can trust Travis.
  • rlwrap lein figwheel (presumably rlwrap doesn't matter ;))
  • helm-find-files to go to that new directory
  • C-c M-c (cider-connect) to localhost, port 7002. REPL appears, works fine (this is a Clojure REPL).
  • In REPL, eval: (use 'figwheel-sidecar.repl-api) (figwheel-sidecar.repl-api/cljs-repl). This will block until you open a browser and go to localhost:3449. Once that is done, Clojurescript REPL appears, and works fine.
  • Go to src/reason/core.cljs, C-c , (cider-test-run-tests). *Messages* shows:
Running tests in reason.core-test...
No tests namespace: reason.core-test
  • Go to test/reason/core_test.cljs. C-c , again. Same messages.
  • Still in core_test.cljs, compile buffer (C-c C-k). Works fine. C-c , still fails, even now there's definitely a namespace reason.core-test. Verify this by, in the core_test.cljs buffer, doing C-c M-n, and evaling e.g. prefix-test.
  • Go to core.cljs, C-c , still fails with the same error, but recompiling (C-c C-k) works fine, evaling things in the REPL after switching to that ns works fine.

Given your earlier comments I'm guessing you can reproduce everything, except that C-c , just works? If so, at least that will give me somewhere to start digging.

@expez
Copy link
Member

expez commented Nov 29, 2015

@lvh I was going by @sp3ctum's comments. I got the impression it was working fine for him and that this was about the structure of the project.

@expez expez reopened this Nov 29, 2015
@lvh
Copy link
Author

lvh commented Dec 24, 2015

@sp3ctum: Could you check if the above repro works for you?

@mikavilpas
Copy link

Hi guys, I just tried with @lvh 's repro instructions, and could reproduce everything just like he said.

; CIDER 0.10.0 (Java 1.7.0_06, Clojure 1.7.0, nREPL 0.2.12)
emacs-version
;; => "24.5.1"

On Windows 7, did not use rlwrap :)

@mikavilpas
Copy link

Actually I can reproduce this in another project as well. I never used the feature with cljs so I must have missed the fact it did not work.

@gdanov
Copy link

gdanov commented May 15, 2016

running tests in clojurescript is currently not working according to the docu and the source I've read

@LeaveNhA
Copy link

LeaveNhA commented Dec 3, 2017

Is problem still available ?

@mikavilpas
Copy link

Yes, this problem is still unresolved.

I can reproduce it in my project here https://github.com/sp3ctum/squanmate like this:

  • open a test file in emacs
  • M-x cider-jack-in-clojurescript
  • cider-test-run-project-tests

When doing this, I get this output:
helm-M-x: ‘cider-test-run-project-tests’ doesn’t support ClojureScript

Using

CIDER 0.15.1snapshot (package: 20170729.133)

@LeaveNhA
Copy link

LeaveNhA commented Dec 4, 2017

I am on it, but I am so newbie.
I am not expecting a result in 10 days.

@sp3ctum, Thanks for the reply!

@kurt-o-sys
Copy link

Having the same issue...

Connected to nREPL server - nrepl://localhost:39960
CIDER 0.17.0snapshot (package: 20180124.1228), nREPL 0.2.13
Clojure 1.9.0, Java 1.8.0_152 

@mikavilpas
Copy link

In my case, I was able to work around the issue by using doo which was a really easy way to setup a continuous test runner (watcher) that compiles cljs->js and then runs unit tests.

If you're struggling with running your tests, maybe that can help right now.

@kurt-o-sys
Copy link

I agree, that's for running all tests...
But it doesn't solve the problem to run tests with cider-nrepl. It's pretty nice to just run a test (and show the result inline) with a shortkey from you editor while programming. I'd love to have that functionality in cljs. Not sure how to do that with doo.

@mikavilpas
Copy link

mikavilpas commented Jan 26, 2018 via email

@kurt-o-sys
Copy link

Yeah, it's not only about having a lot of failures, it's also about: if I need only 1 or 2 tests to run, I don't want to compile and run everything over and over again. It'd be about checking my cljs code (not about a full compiled version of my app). Anyway... I'd just love to see running tests working, so I can integrate it in my workflow similar to what I do in clojure.

@stale
Copy link

stale bot commented May 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale label May 8, 2019
@bbatsov
Copy link
Member

bbatsov commented May 14, 2019

The test runner functionality is Clojure-only at the moment. Changing this is on the roadmap, but given our limited resources I doubt we'll tackle it soon.

@bbatsov bbatsov closed this as completed May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants