These are chat archives for jdubray/sam

10th
Aug 2016
Vincent Jo
@chiwoojo
Aug 10 2016 00:03
@jdubray that Ng-cli is neat
Hey guys what came out of the conversation regarding timeouts?
In SAM
I'm going to run into doing timeout at work and I've been integrating SAM and I was wondering if i should put it in the action or display function
Fred Daoud
@foxdonut
Aug 10 2016 00:14
@edmulraney @devinivy interesting, I'm using mocha but open to trying something else... what would be the differences between ava and lab?
Jean-Jacques Dubray
@jdubray
Aug 10 2016 00:34
@chiwoojo
1/ it's totally cool to use timeout to delay the call to the present method
2/ on event, small DOM manipulations are allowed in the view components (such as starting a spinner)
3/ on display you can also use timeouts to delay the execution of a function which manipulates the DOM (delayed rendering of the state representation).
There is reason why any of these timeouts would "break SAM", perhaps #2 is limit, since you are manipulating the state representation outside the SAM loop, therefore you should use it sparsely.
A delayed action is used to do some "cleanup"
A delayed state representation display is more about UX
Edward Mulraney
@edmulraney
Aug 10 2016 09:08
@foxdonut i found ava removes a lot of bloat from your tests. the two main reasons I use ava are, 1. it runs tests in parallel. much much faster than any other testing framework i've used. 2. it's error reporting feedback is better than any I've seen. you don't just see the internal guts of an error message you get feedback like this:
https://github.com/avajs/ava/raw/master/media/stack-traces.png
The test syntax is very simple too. you can use any assertion library you want. I use chai.
tbh the github page sells it really well: https://github.com/avajs/ava
Fred Daoud
@foxdonut
Aug 10 2016 13:20
@edmulraney ooooh besides all that plus no globals etc., there is one thing that would make my tests cleaner with ava: t.plan. Some of my tests have multiple callbacks, for which I don't want the test to rely on order. Using mocha's done() is not enough, so I have a counter to keep track and make sure all the assertions have executed -- quite hacky. t.plan would solve that, I think.
To be honest though I did not do research on how to solve this problem with mocha.
devin ivy
@devinivy
Aug 10 2016 13:33
i do love plan()...
lab also has plan but it's used slightly differently.
the key is to have an assertion library that interfaces with your test suite!
Fred Daoud
@foxdonut
Aug 10 2016 13:45
Why the need to add chai? I thought you could just use t.is, t.deepEqual, etc.
Edward Mulraney
@edmulraney
Aug 10 2016 13:48
you can, but chai adds a nicer syntax imo, also extra features not in t.*
and also because I combine it with chai-sinon and chai-enzyme. it's all consistent api
Fred Daoud
@foxdonut
Aug 10 2016 14:04
I see, cool
@edmulraney how does using chai interact with using t.plan?
Fred Daoud
@foxdonut
Aug 10 2016 14:16
I also like that you can add a message to an assertion :thumbsup:
Edward Mulraney
@edmulraney
Aug 10 2016 14:30
@foxdonut it's something we lose out on by using chai. it's main use is for promises right? for other issues like mispellings, that was recently added to chai: chaijs/chai#721
devin ivy
@devinivy
Aug 10 2016 14:39
the way code handles misspellings is different. it makes you call the end of the chain as a function. if it's misspelled you'll get undefined is not a function.
expect(x).to.be.a.function() over expect(x).to.be.a.function
Edward Mulraney
@edmulraney
Aug 10 2016 15:18
the recent change they added now highlights problems like:
expect(x).to.be.ture instead of expect(x).to.be.true
which used to get swallowed
Fred Daoud
@foxdonut
Aug 10 2016 16:24
Thanks for the reference to AVA, @edmulraney , I may convert the Meiosis tests to it.
Edward Mulraney
@edmulraney
Aug 10 2016 16:24
no prob, i only converted recently also. been a breeze so far
TJ (the guy who made mocha), said that if he was to redesign mocha from the start, he would make it like AVA
Fred Daoud
@foxdonut
Aug 10 2016 16:25
Besides what we've already said, I also like that you don't have to add an assertion library if t.xxxx functions suit your needs; and also, works nicely with TypeScript (which I am using for Meiosis.) :thumbsup:
Vincent Jo
@chiwoojo
Aug 10 2016 16:29
@jdubray thanks JJ
Jeff Barczewski
@jeffbski
Aug 10 2016 18:44
@edmulraney @jdubray I prefer npm scripts over gulp and grunt too. It's much better to build things up that way. I do occasionally use webpack for some things too, but I kick them all off from npm scripts. Much easier to maintain and change over time, especially adding new items to the pipeline. Composes nicely.
@devinivy I liked lab too, but I wish they would make it work in browser too, so for this reason I use mocha since I can use the same thing everywhere node, browser with karma, even for selenium testing with web driver (mocha can drive).
@foxdonut I used to use chai but have moved to Michael Jackson's expect instead. It has just what I need, the code is simple. I got tired of all the extra chaining nonsense. expect is simple, limited, and fits the bill.
devin ivy
@devinivy
Aug 10 2016 18:49
didn't realize lab doesn't work in browser, though not surprised cause it probably uses hoek, which uses crypto. in-browser i do use mocha plus the web component tester.
even when i'm not testing web components.
Jeff Barczewski
@jeffbski
Aug 10 2016 19:02
@edmulraney the stack trace cleanup looks nice in ava. I'm hesitant to use parallel tests though since that really limits the types of things you can do. I understand that it is nice to have everything be able to run in isolation but getting everything there is another thing. I also do run system tests so one would need separate db's for things like that. We were using tap before mocha came out and it ran things in parallel, but we found that it made things much less predictable, so when mocha came out and it ran things in serial that was better for us at the time. I guess if you can somehow isolate things well it could work, but I don't like mocks much and thus I guess I'll stick with a serial approach. Normally everything I run is pretty fast anyway except for selenium tests and those should be run on a grid anyway.
Jeff Barczewski
@jeffbski
Aug 10 2016 19:11
I see that ava does run those in separate processes so that would certainly help.
Fred Daoud
@foxdonut
Aug 10 2016 21:53
@jeffbski thanks for the reference to MJ's expect, looks good!