react

pesterhazy 2021-10-10T16:39:08.110300Z

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!

pesterhazy 2021-10-11T07:03:18.114400Z

Oh wow, there must be something funny going on there

Lucy Wang 2021-10-11T12:16:57.114600Z

@pesterhazy 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

pesterhazy 2021-10-11T18:05:50.114900Z

wow!

pesterhazy 2021-10-11T18:06:07.115100Z

$ 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.

pesterhazy 2021-10-11T18:06:39.115300Z

first run with transformer: {} -> 1.7s

pesterhazy 2021-10-11T18:06:56.115500Z

second run with transform: undefined (defaulting to babel) -> 9.7s

1
pesterhazy 2021-10-11T18:07:14.115700Z

great find, thanks @wxitb2017

Lucy Wang 2021-10-11T01:41:19.111Z

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/ .

👀 1
Lucy Wang 2021-10-11T01:42:29.111300Z

I think your way of compiling to "npm-module" target is better than compiling into "node-script" target.

Lucy Wang 2021-10-11T05:04:18.111600Z

@pesterhazy 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.

pesterhazy 2021-10-11T06:32:33.113600Z

Is the compile step slow or the run in jest? How long does a run take?

Lucy Wang 2021-10-11T06:33:06.113800Z

Compile is fast. Jest run could take a minute and sometimes node process died of OOM