This project is for creating mock API and Real-Time testing.
- Architecture: Single Page Application (SPA)
- Languages
- Front end is ClojureScript with (re-frame)
- Dependencies
- Build tools
- CLJS compilation, dependency management, REPL, & hot reload:
shadow-cljs - Test framework: cljs.test
- Test runner: Karma
- CLJS compilation, dependency management, REPL, & hot reload:
- Development tools
- Debugging: CLJS DevTools,
re-frame-10x, - Linter: clj-kondo
- Debugging: CLJS DevTools,
Use your preferred editor or IDE that supports Clojure/ClojureScript development. See Clojure tools for some popular options.
- Install JDK 8 or later (Java Development Kit)
- Install Node.js (JavaScript runtime environment) which should include NPM or if your Node.js installation does not include NPM also install it.
- Install Chrome or
Chromium version 59 or later
(headless test environment)
- For Chromium, set the
CHROME_BINenvironment variable in your shell to the command that launches Chromium. For example, in Ubuntu, add the following line to your.bashrc:export CHROME_BIN=chromium-browser
- For Chromium, set the
- Install clj-kondo (linter)
- Clone this repo and open a terminal in the
mock-uiproject root directory - (Optional) Setup lint cache:
clj-kondo --lint "$(npx shadow-cljs classpath)" - Setup
Start a temporary local web server, build the app with the dev profile, and serve the app,
browser test runner and karma test runner with hot reload:
npm installnpx shadow-cljs watch appor
npm run watchPlease be patient; it may take over 20 seconds to see any output, and over 40 seconds to complete.
When [:app] Build completed appears in the output, browse to
http://localhost:8280/.
See
Shadow CLJS User's Guide: Editor Integration.
Note that npm run watch runs npx shadow-cljs watch for you, and that this project's running build ids is
app, browser-test, karma-test, or the keywords :app, :browser-test, :karma-test in a Clojure context.
Alternatively, search the web for info on connecting to a shadow-cljs ClojureScript browser REPL
from your editor and configuration.
For example, in Vim / Neovim with fireplace.vim
- Open a
.cljsfile in the project to activatefireplace.vim - In normal mode, execute the
Piggiebackcommand with this project's running build id,:app::Piggieback :app
-
Connect to the
shadow-cljsnREPL:lein repl :connect localhost:8777
The REPL prompt,
shadow.user=>, indicates that is a Clojure REPL, not ClojureScript. -
In the REPL, switch the session to this project's running build id,
:app:(shadow.cljs.devtools.api/nrepl-select :app)
The REPL prompt changes to
cljs.user=>, indicating that this is now a ClojureScript REPL. -
See
user.cljsfor symbols that are immediately accessible in the REPL without needing torequire.
Build the app with the prod profile, start a temporary local web server, launch headless
Chrome/Chromium, run tests, and stop the web server:
npm install
npm run ciPlease be patient; it may take over 15 seconds to see any output, and over 25 seconds to complete.
Or, for auto-reload:
npm install
npm run watchThen in another terminal:
karma startBuild the app with the prod profile:
npm install
npm run releasedocker-compose builddocker-compose up -d