cljest
is a way to run your ClojureScript files in Jest. It consists of two packages, one in Clojure and one in JavaScript, which allow you to take your ClojureScript tests and run them in Jest.
You'll need two packages, cljest
and jest-preset-cljest
.
Install jest-preset-cljest
using NPM (or Yarn):
npm add --save-dev jest-preset-cljest@1.0.0
And then add cljest
to your deps.edn
or analagous file:
{:deps {com.pitch/cljest {:mvn/version "1.0.0"}}}
For more details, as well as details about getting started and configuration, please see the Installation documentation.
Installation
Writing your first test
Migrating from cljs.test
to cljest
and differences
Unit tests
Component tests
Mocking
Async code
General API docs
Running in CI/noninteractive environments
Important information about library versioning
Troubleshooting
Succinctly:
cljest
has a special async
macro to make dealing with async code easier. No more hanging promises in your tests!jsdom
, an environment that lets you mimic a real DOM environment without spinning up a browser, letting you easily test your Reagent, UIx, Helix, or other components, and supports creating snapshots of your components so that changes to the implementation detail of your components doesn't change what the user sees. It also supports mocking timers like setTimeout
and process.nextTick
so that you can have complete control over how time advances in your code, removing the need to mock or abstract timers away yourself.testing-library
for good testing practices, jest-axe
for accessibility, and more. Jest is also part of the OpenJS Foundation.The following items, in no particular order, are on the roadmap as potential additions or improvements to cljest
:
Firstly, thanks!
Secondly, please fork the repository and create a PR with your changes. Just keep a couple of things in mind:
cljest
, and otherwise (or if your code is Clojure, not ClojureScript), write your tests in Kaocha.If something isn't working right, and it's not covered by the troubleshooting documentation, or if something is missing, or if you just generally encounter issues, please create an issue.
MIT
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close