Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As much as Pivotal's support for jasmine is a bit hit and miss (minimal new development, lots of unanswered issues/pull-requests on their github), <a href="https://github.com/pivotal/jasmine/" rel="nofollow">Jasmine</a> is a really good tool for testing client-side code, mainly because of <a href="https://github.com/velesin/jasmine-jquery" rel="nofollow">jasmine-jquery</a>. </p> <p>Jasmine's general approach is pretty solid and Jasmine-Jquery has a lot of great matchers for testing the DOM, as well as great DOM sandboxing. </p> <p>I found testing on the client-side a challenge, mainly because I had to stop being so rigid and prescriptive in my tests.</p> <p>Generally, you should approach client-side testing in a kind of 'fuzzy' way, testing the DOM hierarchy too specifically is a road to hell. Test things like, "Does the page contain these words" over "Does div id#my-div contain a ul with 3 li's with content that matches this regex"</p> <p>The latter is how I started doing tests but I found it incredibly time consuming and fragile; if the designer (me) want to mess with the structure, it'd could unnecessarily break many tests. The only way to get around it is to create 'widgets' for each component, which would be ideal but as I said, very time consuming, it actually became a running joke at my office: "how many tests you done this week Tim? 2? 3? Wow 3 tests. Good work." </p> <p>Anyway…</p> <p>You can get 90% of the benefit of doing client-side testing by testing loosely, and focusing on what's important, such as workflow and data 'presence' over specific content in a specific location in the hierarchy on the page.</p> <p>edit: Also, ensure you break the business logic into units that are independent of the DOM, as much as humanly possible. That makes your life a lot easier, and generally leads to better architecture, which is a plus.</p> <p>edit 2: You might want to look into how the Rails world does this using Capybara/Cucumber or Selenium.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload