Feed Reader Testing
This is the fourth project from the Front-End Web Developer Nanodegree by Udacity. It's a web-based application that reads RSS feeds and my challenge was to complete the test suite using Jasmine.
Practicing TTD (Test-Driven Development) is a good way to guide your development process, as it allows you to create a testable software at the forefront. By the time you're done with development, you already have a tested software that can be pushed to production and that will certainly work.
Process
- In the first test, I used the
forEach
method to loop within theallFeeds
object and check if there was anurl
element defined in the array. I used thelength
property andnot.toBe
expectation to check the existence of the element. - The second test was basically the same, but this time I wanted to check the
name
element inside the array. - In the third test, I accessed the
body
element using the document object with thehasClass
method, to check if the element had themenu-hidden
CSS class set by default. - The fourth test was about triggering
click()
events, to expect the existence of themenu-hidden
class on thebody
element and, with that, the visibility change of the menu. - In the Initial Entries test suite, I used the
beforeEach
hook and asynchronousdone()
function so that I could check if the.entry
element, combined with thelength
property, would correctly answer thetoBeGreaterThan(0)
expectation. - For the last, and most difficult test suite, I reused the same hook and asynchronous function from the previous test, added a callback with a new instance of the same element ant then compared them with a
not.toEqual
expectation.
How to run the test
Download or clone this repository and open the index.html
file in your favorite browser. You can also access the RSS Feed application test page.