This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-10
Channels
- # announcements (1)
- # asami (36)
- # babashka-sci-dev (5)
- # beginners (4)
- # calva (10)
- # chlorine-clover (2)
- # clj-commons (2)
- # clojure (35)
- # clojure-android (1)
- # clojure-norway (1)
- # clojurescript (11)
- # cursive (8)
- # deps-new (5)
- # emacs (8)
- # fulcro (11)
- # graalvm (15)
- # gratitude (5)
- # holy-lambda (11)
- # jobs-discuss (5)
- # lsp (9)
- # off-topic (9)
- # other-languages (2)
- # pathom (6)
- # polylith (43)
- # portal (35)
- # quil (6)
- # react (13)
- # reclojure (3)
- # releases (5)
- # rewrite-clj (13)
- # shadow-cljs (32)
IMO the future of testing CLJS frontend apps is Jest I've build a proof-of-concept todomvc app using TDD here. Rationale in the README: https://github.com/pesterhazy/shadow-jest — feedback welcome!
Nice try! Actually there is another similar effort in the community, but with mocha instead of with jest https://www.reddit.com/r/Clojure/comments/px001o/using_mocha_to_test_clojurescript/ .
I think your way of compiling to "npm-module" target is better than compiling into "node-script" target.
@U06F82LES I just played your demo repo and it works pretty well. But when I adopts it to one of my real world projects, it became extremely slow. By bisecting the deps it looks like sci and malli is the culprit.
Is the compile step slow or the run in jest? How long does a run take?
Compile is fast. Jest run could take a minute and sometimes node process died of OOM
Oh wow, there must be something funny going on there
@U06F82LES this is fixed by adding transform: {}
to jest.config.js. By default jest would transform .js files with babel so that could be the problem
https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object
$ npx jest --no-cache
PASS dist-test/todomvc.app_spec.js
✓ initial screen (123 ms)
✓ add todo (27 ms)
✓ can't create empty todo (15 ms)
✓ remove todo (18 ms)
✓ complete todo (21 ms)
✓ select filter (38 ms)
✓ toggle all (20 ms)
✓ edit todo (36 ms)
Test Suites: 1 passed, 1 total
Tests: 8 passed, 8 total
Snapshots: 0 total
Time: 1.749 s
Ran all test suites.
$ npx jest --no-cache
PASS dist-test/todomvc.app_spec.js (9.206 s)
✓ initial screen (135 ms)
✓ add todo (39 ms)
✓ can't create empty todo (17 ms)
✓ remove todo (19 ms)
✓ complete todo (24 ms)
✓ select filter (35 ms)
✓ toggle all (20 ms)
✓ edit todo (40 ms)
Test Suites: 1 passed, 1 total
Tests: 8 passed, 8 total
Snapshots: 0 total
Time: 9.72 s
Ran all test suites.
first run with transformer: {}
-> 1.7s
great find, thanks @UP90Q48J3