These are chat archives for mithriljs/mithril.js

31st
Oct 2015
Rodrigo Álvarez
@Papipo
Oct 31 2015 00:04
should I need anything special to test my app with mocha given it needs WebSQL?
I am trying to connect with persistencejs and it throws and error, I think that it's just because node does not have support for that, does it?
Rodrigo Álvarez
@Papipo
Oct 31 2015 00:51
do I need a shim or something?
Rodrigo Álvarez
@Papipo
Oct 31 2015 10:49
Forget it, I've been able to fallback to a in-memory implementation for tests
Patrik Johnson
@orbitbot
Oct 31 2015 11:12
Newbie question: is there a good semi-comprehensive testing article somewhere for reference? Or should I just re-read the m-query README until enlightenment? :smile:
What are you guys using for testRunner etc setup? Been doing mostly Angular stuff with gulp + karma/protactor along with Mocha/Sinon/Chai
Isiah Meadows
@isiahmeadows
Oct 31 2015 11:17
@orbitbot In the Mithril community, I don't think there is any particular preferred test runner or method. Mithril is pretty unopinionated in that respect. Currently, I'm finishing up rewriting all the Mithril tests in Mocha/Sinon/Chai (part of a large process).
Barney Carroll
@barneycarroll
Oct 31 2015 11:18

@impinball sorry for dropping out of the convo.

Although I don't think we need to use Cito. This is a completely separate implementation, and actually in the same league (with extra features added).

It's a much more performant DOM patcher anecdotally. @lhorie's been talking about a Mithril re-write based on lessons learned there.
I think it would be far easier simply to use it under the hood, rather than write something similar.
In particular, implementing granular redraw would come for free.
Patrik Johnson
@orbitbot
Oct 31 2015 11:24
@impinball :+1:
I'm a bit confused about m.deps, looking at m-query it doesn't really seem to be required for (or maybe abstracted away). Do I need to care about it if I write tests for my components with m-query or is it mostly for Mithril core testing / something else?
Isiah Meadows
@isiahmeadows
Oct 31 2015 11:47
@barneycarroll I see what you're talking about. Make Mithril smaller internally. Cito's also close to the size Mithril's rendering code is now. And building an abstraction over that would be easy.
@orbitbot mithril-query is mostly for users of Mithril, but it wouldn't be that good for testing Mithril itself.
Mithril needs too many low-level concerns tested.
Patrik Johnson
@orbitbot
Oct 31 2015 12:07
I can understand that it wouldn't work for Mithril, yeah. Testing info seems spread a little thin across the documentation so far (not talking about testing Mithril itself), there's nothing in the Guide, the API just mentions m.deps without that much useful information, and the single link under Testing in the wiki points to m-query. None of the starter kits/boilerplate projects that I looked at (a handfull) had any unit/integration test setup at all
I'll have a go at my own basic boilerplate with testing, since I'm going to figure out a basic setup anyways...
Isiah Meadows
@isiahmeadows
Oct 31 2015 13:17
Like I said, Mithril is pretty unopinionated in how you test your app.
Patrik Johnson
@orbitbot
Oct 31 2015 14:28
Yeah, I didn't intend to sound overly critical, it would however be useful for beginners to have something in the Guide pointing you in the correct direction if you feel that you want/should/need to test your mithril components
Isiah Meadows
@isiahmeadows
Oct 31 2015 14:31
I understand.
Barney Carroll
@barneycarroll
Oct 31 2015 14:52
@impinball AFAIC the best parts of Mithril are the view language and the simplicity of core APIs
But really the second part isn't anything magical, and a lot of these APIs are justified by circular logic
Plus components internal logic is kind of a mess. Unnecessarily complicated mostly to make up for technical debt with early decisions (deferred views etc).
Personally I'd be happy to ditch asynchronous components as an implicit convenience and keyed DOM roots to identify component instances if we can get a more modular, maintainable and consumer-flexible kit as a result
The functionality enabled by such APIs can be reintroduced — probably in a more rational way — once we have more traditional core dependencies to use
Isiah Meadows
@isiahmeadows
Oct 31 2015 15:08
@barneycarroll I'm going to here in a few open that large test-related PR.
Just finished it.
Isiah Meadows
@isiahmeadows
Oct 31 2015 15:14
#822
Barney Carroll
@barneycarroll
Oct 31 2015 15:15
!! :clap:
Isiah Meadows
@isiahmeadows
Oct 31 2015 15:17
@lhorie You'll appreciate my most recent PR.
I'm so happy I finally finished it. After it gets merged, I'm going to tackle "mithril.js" proper itself.
Arthur Clemens
@ArthurClemens
Oct 31 2015 15:49
great work
Barney Carroll
@barneycarroll
Oct 31 2015 16:25
You'll be in a great position to do that :D
The tests are awesome
Well done
So IMO — not to do down any of your work — test/mithril.js should be subdivided into the stuff that produces vdom and the more mixed concerns
Barney Carroll
@barneycarroll
Oct 31 2015 17:46
BTW at the risk of sounding like a total traitor, I actually think React's component API is totally awesome
Grant Miner
@llambda
Oct 31 2015 18:30
What's better about it?
Barney Carroll
@barneycarroll
Oct 31 2015 18:36
Consistent this, a whole slew of methods that adequately describe the various granular lifecycle hooks
I've been toying with verbs like move and exit but ultimately the for things like efficient diffing and transitions etc an acknowledgment of a higher order of complexity for the view loop is kind of necessary
Otherwise you end up with clumsy notions like onunload and init which aren't sufficiently precise or reliable
Barney Carroll
@barneycarroll
Oct 31 2015 19:06
By getting access to state at such moments, you enable for example getting an component's root element position before it disappears from one place and appears in another, after which point you can put conditionals in the view to enable a contextual animation from X to Y (ie this item moved up in a list, etc)
I think this kind of fine-grained introspection of the draw process is essential for Mithril's long term viability
Grant Miner
@llambda
Oct 31 2015 19:14
That sounds very useful.
Dominik Dumaine
@Bondifrench
Oct 31 2015 22:34
great work @impinball :clap: