CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • Javascript and testing
Pages: [1]

Author Topic: Javascript and testing  (Read 1037 times)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Javascript and testing
July 02, 2014, 05:42:01 pm
I did some investigation of AngularJS's recommendations on testing to see how it might work with Civi. A few thoughts (in no particular order):

1. They recommend implementing tests with Jasmine -- which I haven't used before. I have used qunit.
 * Awesome: Shows up in tutorials, documentation, and other discussions about Angular testing
 * Neutral: At first glance, nothing really stands out as comparatively excellent or terrible with Jasmine -- it just seems different.
 * Weak: We have a qunit tests already -- but not very many. If we adopted Jasmine, we'd probably want to port over the qunit tests.

2. For unit-tests, they recommend http://karma-runner.github.io/0.12/index.html
 * Awesome: Shows up in tutorials, documentation, and other discussions about Angular testing
 * Awesome: Supports concurrent testing in multiple browsers
 * Awesome: Automatic test execution
 * Awesome: Outputting results to file (for use with continuous-integration).
 * Weak: Would take some work to incorporate into buildkit because...
 * Weak: Pure Javascript architecture requires additional tools that aren't in standard LAMP stack
 * Weak: Requires creating more config files with details about local system.
 * Weak: No attention to integration testing -- tests that communicate with server-side are out-of-scope/extra-work

3. For integration tests ("end-to-end / e2e"), they recommend https://github.com/angular/protractor
 * Awesome: Shows up in tutorials, documentation, and other discussions about Angular testing
 * Awesome: Use the same test runtime as karma (ie jasmine)
 * Weak: Use a different test runtime from PHP (ie phpunit) (Can't have it both ways!)
 * Awesome: When I think about testing inside a browser, my brain shifts more naturally into JS than PHP. It's been trained to think that browser==JS.
 * Weak: No way to do assertions with server-side state (eg "did that AJAX call really update the DB? did it really write to a log file? did it really use the mock email service?")
 * Weak: As with karma, the JS bias and extra config files require more work for buildkit.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Javascript and testing
July 03, 2014, 12:15:25 am
We use jasmine as well on dc.js
https://github.com/dc-js/dc.js/blob/master/spec/pie-chart-spec.js

pro:
Easy to test a single test in the browser (eg. when you debug or write one, you just put breakpoints and look what you have vs. what you test)
integrates well with grunt + phantomjs and you can run webtests from a command line with a fairly enjoyable speed (eg. on dc 777 specs in 14.007s.)

All in all, jasmine+grunt is the most enjoyable test framework I've experienced. This being said, it's a js library so it might be easier to test than when you have a backend in php+mysql.

X+

I don't know karma-runner
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • Javascript and testing

This forum was archived on 2017-11-26.