Client side test in Drupal -- let's figure this out

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by jessebeach on December 15, 2013 at 8:51pm

Much of our front end testing effort has gone into the TestSwarm module (the platform) and the Frontend Automated Tests module (the tests).

Having written several tests now, I've come to the following conclusions:

  • We have better tools at our potential disposal to allow non-technical folks (UX, documentation, etc) to define what behaviors they expect from a feature; later a technical person can translate this description in to tests.
  • QUnit, the framework we're using now, has bad support for asynchronous tests. The syntax quickly becomes unruly and verbose. A framework like Jasmine has much better support for asynchronous functionality.

Below are some links about discussions that have already happened. I'm sure there are more links I could add here regarding what others have said about front end testing in Drupal. Please add additional links in comments if you think they are relevant.

DrupalCon Portland 2013: AUTOMATED TESTING WITH JASMINE AND PHANTOMJS

DrupalCon Prague 2013 :JAVASCRIPT TESTING

Next Steps

I would like us to come to conclusion on the following questions:

  1. What framework should we use for behavior driven development?
  2. Is there a common syntax across BDD frameworks that would allow us to start writing descriptions of feature behavior prior to picking a framework?
  3. What framework should we use for writing assertions?
  4. Is our QUnit/TestSwarm combo good enough for our needs? Have you personally had success with this combo?
Categories:

Comments

I believe JS testing was

Posted by chx on December 15, 2013 at 10:08pm

I believe JS testing was discussed at DC SF some 3.5 years ago and we were thinking that we would ask people to point their browsers to a swarm page and so we can test with real browsers for free. This doesn't require money or knowledge from contributors so it could become a very easy way to contribute.

:-)

Posted by As If on December 15, 2013 at 10:18pm

CrowdSwarming. Nice.

Chx linked me to this page in

Posted by jessebeach on December 15, 2013 at 10:18pm

Chx linked me to this page in chat, a recap of DrupalCon San Francisco: http://marvil07.net/blog/2010/drupalcon-san-francisco-2010-or-why-i-love...

which lead me to this issue that I hadn't known about before about establishing a front end testing framework: https://drupal.org/node/237566

What I would really really

Posted by jessebeach on December 15, 2013 at 10:19pm

What I would really really really like to hear from folks in the community is their success or failure stories employing various combos of tools.

via @seutje Google's

Posted by jessebeach on December 15, 2013 at 10:56pm

via @seutje

Google's migration to Selenium 2.0

https://www.youtube.com/watch?v=cSLmfegT36A

My impressions regarding Front-end Automated Testing

Posted by rteijeiro on December 16, 2013 at 9:00am

Hi, after speaking about Front-end Automated Testing in a few Drupalcamps around Europe, I had the opportunity to discuss with several Drupal folks about their solutions for front-end testing:

  • The most used framework is Selenium but it's not a front-end specific testing framework. As well is difficult to setup and configure for front-end developers so I would not consider it as a solution.

  • Mostly commonly used framework is CasperJS. I can say that it's a powerful front-end testing framework and, in combination with PhantomJS, it could fit in most common environments. I have also tried DalekJS that, despite being so new, it seems to will be a good framework in a future.

@jessebeach, answering your questions:

  1. Jasmine.
  2. There is no standard but I think something like Gherkin could fit our needs: https://github.com/cucumber/cucumber/wiki/Gherkin
  3. My experience is that QUnit fits my expectations in most common scenarios. But, if we want a solution for Drupal 8, maybe we should consider also testing frameworks for Backbone like http://backbone-testing.com
  4. Definitely sure. It fix really well with jQuery and javascript code in Drupal, as far as I tested it.

We can discuss this longer if you want. I think we need to spend some time looking for a good solution for our needs.

Calm Down & Clear the Cache

More resources

Posted by vladan.me on December 17, 2013 at 11:33am

I have to agree with @rteijeiro, moreover I really like and recommend this presentation:
http://www.slideshare.net/Phase2Technology/testing-withghostsandgherkins

CasperJS seems like a very nice solution. Syntax-wise looks like traditional SimpleTest framework (asserts and similar) and is also JavaScript friendly, you can even use jQuery if you are not familiar with classic selectors provided for interaction with DOM. I mean, I feel that it may be well adopted if chosen as a solution. DalekJS mentioned I have never tried but seems like a very young project, need to be monitored but certainly not to be used right now.
On other hand, about Jasmine, syntax is bit strange, no (e.g. spies. mocking?!), I have never tried, is just first look, not sure about usage. Can't all that functionality be replaced with only CasperJS or I am missing something?

vladan.me, rteijeiro, it

Posted by jessebeach on December 17, 2013 at 6:42pm

vladan.me, rteijeiro, it seems like could start writing feature description in Gherkin now.

https://github.com/cucumber/cucumber/wiki/Gherkin

And this wouldn't limit us in terms of the assertion library we use down the line.

Thoughts?

Javascript

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /