Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing JS - In Rails

Romeeka Gayhart
August 15, 2016
41

Testing JS - In Rails

Romeeka Gayhart

August 15, 2016
Tweet

Transcript

  1. Feature Testing Acceptance Test Written from the perspective of a

    user clicking around an application Where multiple modules or sections of code are combined and tested as a group Integration Testing Where the smallest testable part of an application is tested. Unit Testing
  2. An ‘all in one package’ for testing. You’ve seen it

    when you do Exercisms. Jasmine A ‘simple, flexible, fun’ testing framework - meaning you have to include utility libraries like Chai for things like ‘assertions’ Mocha Testing Frameworks
  3. Two Potential Fixes A function that takes in a value,

    such as an idea’s existing quality and returns a value, such as the idea’s new promoted value Treating Idea as a ‘class’ or ‘object’, separate from the DOM, and testing that our function changes that object when called
  4. Two different gems maintained by the Jasmine Core team/Justin Searls

    that specifically integrate Jasmine and Rails Jasmine Gem or Jasmine Rails Teaspoon is a bridge that lets your JavaScript testing framework of choice hook into the Asset Pipeline. As a bonus, it includes many of the libraries needed to get up and running testing JavaScript Teaspoon Some Resources
  5. Capybara tests operate by instructing a browser to interact with

    a website in a test environment Capybara uses the same Domain Specific Language to drive a variety of browser and headless drivers. RackTest Selenium Capybara-webkit Poltergeist
  6. Brittle. Add up quickly, time-wise
 
 Can be difficult to

    configure Cons The most accurate simulation of a user’s experience Pros
  7. You will need to install and configure a JavaScript Driver

    Selenium Capybara-webkit & Poltergeist Will open a browser and click around while you watch it. Good for debugging, bad for test suite speed. Will run ‘headless’ (without opening a browser) - can be difficult to debug and may have consequences for transactional tests.
  8. You will also need to let Capybara know that you

    are testing a feature with JavaScript functionality