I am trying to set up Cypress tests written in ClojureScript for a project that uses lein-cljsbuild . Using the following configuration, I can compile one test namespace into a single .js file:
:cljsbuild {:builds [{:id "cypress" :source-paths ["test/cypress"] :compiler {:optimizations :simple :main "specs.login-spec" :output-to "cypress/integration/login_spec.js" :output-dir "test-resources/cypress/js/build/"}}]}
The above works fine and runs correctly in Cypress.
Now I want to scale it. Here are my requirements:
- have several specifications written in ClojureScript:
specs.login-spec , specs.shopping-cart-spec , specs.checkout-spec , etc. (I expect them to have dozens). - I want Cypress to recognize them as separate test suites (for example, I can run them myself). This means that each ClojureScript test namespace must end in a separate JS file, which is self-contained, that is, independent of any other JS file.
- I want to be able to compile all the specifications fast enough.
- I want the source view to be available as it is with a simple setup, i.e.
lein cljsbuild auto … should still work and use incremental build.
How to do it?
The most naive approach is to specify one build plan for each specification. But this will mean that for N specifications, I will need to compile N times. It will be very slow.
The only idea that popped into my head was ClojureScript modules, but the following setup emits empty files:
{:id "cypress" :source-paths ["test/cypress"] :compiler {:optimizations :simple :output-dir "test-resources/cypress/js/build/" :modules {:m1 {:output-to "cypress/integration/login_spec.js" :entries #{"specs.login-spec"}} :m2 {:output-to "cypress/integration/checkout_spec.js" :entries #{"specs.checkout-spec"}}}}}
My spec files are very simple right now - and individually, they compile and run in Cypress just fine. Example:
(ns specs.login-spec (:require [tools.commands] [tools.interop :refer [cy describe it]])) (describe "Lorem" (fn [] (describe "Ipsum" (fn [] (it "Blah!" (fn [] (-> cy (.LogInAndNavigate) …)))))))
source share