Testing strategies


#1

Currently we don’t write any tests but we want to. So now we are investigating how we can get started with it.

Are there any guides on testing?

How do you guys test?

  • Do you use QUnit / FuncUnit? Or are you moving to other frameworks like Jest, Cypress, …
  • How do you write tests for VM’s?
  • Do you only unit-test or also e2e tests?

Can someone point us in a (any) direction?


#2

We plan to write a Testing Guide in the coming weeks/months. Here is the issue: https://github.com/canjs/canjs/issues/3862. If there are other things you’d like to see on it, please feel free to comment there.

My personal strategy is to write 99% of an app’s tests as unit tests, since they are fast to write and fast to execute. The best tests are tests that you and your team will actually run all the time. The other 1% is usually functional smoke tests with FuncUnit.

For unit testing, you can pretty much pick whatever framework you want. We’ve used QUnit, Mocha, and Jasmine on different projects. They all have basically the same APIs now. I personally prefer Mocha because I think it makes asynchronous tests a little easier to write.

For functional testing, I’ve only really used FuncUnit. cypress.io seems cool, I just haven’t had a chance to try it out.

How to test VMs is a little harder question to answer, but we try to show some of the techniques in the DoneJS guides. If you have more specific questions, let me know and I’ll try to answer as best as I can.


#3

Thx, Kevin!
I forgot about the Testing Guide, I’ll upvote it in the next survey :wink:


#4

It got selected on the last survey, we just haven’t had a chance to work on it yet. :slight_smile:


#5

In the current project that I’m been working, we implement our tests using QUnit/FuncUnit.

We always try to implement unit tests when possible, for instance for Model and VMs tests, but we have a significant percentage of our tests are FuncUnit tests (around 50%), as these are tests are the ones that assures the integration between the components is always working as expected, namely the binding between components.

The consequence of having a significant percentage o Functional tests, is that these tests usually takes more time to run comparing to unit tests.