fulcro

timeyyy 2024-11-29T14:03:39.753979Z

Hi all, i'm embarking on a full stack fulcro app, starting with react native and expo template. I'm interested in setting up some unit tests to help me get things right. I'm mainly looking for examples of tests, or otherwise small examples that would be useful to get me going (examples of tests or anything relevant). Ideally i would be able to run the same test with just swapping out the root component / Actors to my state machine and have the same tests run. I was hoping to get away without needing to render anything. Tips on where to look / how to proceed would be welcomed.

tony.kay 2024-11-29T16:19:58.843229Z

So, the design of Fulcro is very much intended to have you testing state, NOT UI. Fulcro and all of it’s libraries are CLJC, so if you write everything IN CLJC, you can run a data-centric test suite on ALL of your code. Just make the rendering stuff in #?(:cljs) blocks, and write CLJ-only tests.

tony.kay 2024-11-29T16:20:44.516219Z

You might also look at my work-in-progress on statecharts. I have a new way of composing Fulcro apps I’m experimenting with, which has you write the entire application using statecharts. It’s what I’m going to be using for ALL new apps myself.

tony.kay 2024-11-29T16:21:11.452149Z

Here are two repos related to native, and statecharts (NOTE the statecharts work isn’t released, but it is on github)

tony.kay 2024-11-29T16:23:13.962589Z

Here is a git repo of a young woman I’m helping learn Fulcro/Clojure where we set up a native app…the latest expo is kind of hard, so I’d recommend looking over how we set the “Root” “app” and client up, and use that version of expo if you can. The template is out of date. If you want to send a PR to update the template I would appreciate it. https://gitlab.com/shakira1974949/fulcro-native-app

tony.kay 2024-11-29T16:24:02.193909Z

This is the repo of my experimental work on statecharts. https://github.com/fulcrologic/fulcro-with-statecharts

tony.kay 2024-11-29T17:46:36.201049Z

And of course if you read the statecharts docs https://fulcrologic.github.io/statecharts/ there is a section on testing those as pure data/code: https://fulcrologic.github.io/statecharts/#_testing

tony.kay 2024-11-29T17:47:05.594389Z

I highly recommend statecharts over the legacy UI State Machines.

janezj 2024-11-29T22:01:20.010679Z

@tony.kay so what are planning to do with RAD and statecharts? will defstatemachine stay in RAD or will be replaced by statecharts in new major version?

tony.kay 2024-11-29T23:02:47.224619Z

I try very hard to never remove things. That is an incompatible change. Statecharts (the library) will be gaining better integration features.

1
tony.kay 2024-11-29T23:03:18.876309Z

so you can start to adopt those things as needed

timeyyy 2024-11-29T23:14:05.598589Z

great i'll take a look. So the RAD will be made legacy as well? I had to make a few changes to the template which i will make a pr for. I suppose things will still change alot on that front of statecharts is the way forward.

tony.kay 2024-11-29T23:21:42.244089Z

no RAD isn’t going anywhere

tony.kay 2024-11-29T23:22:22.766719Z

My plan is to make a 100% feature-compatible statechart that will run forms/reports, which you can put on a form or report instead of UISM

tony.kay 2024-11-29T23:22:50.031399Z

so, literally just add a so/statechart foo option to a RAD component, and use the statecharts routing abstraction