GithubHelp home page GithubHelp logo

udacity_jasmine_testing's Introduction

Udacity - Jasmine UI testing

RMIT project 3 - Feeder reader testing

Objective

This is a project to test a feedReader code in Jasmine.js with jQuery to select DOM elements. I am given a web-based application that reads RSS feeds. The application has incomplete Jasmine test suites, and I write the remaining test suites and get them to pass. The goal is to learn about JavaScript testing, which is an important part of the development process and many organizations practice a standard known as "test-driven development" or TDD.

How to Run the Application

  1. Download or clone this repository.

  2. Find the index.html file, and open the file in a web browser.

  3. The Jasmine tests are displayed at the bottom of the index.html page.

  4. Open the jasmine/spec/feedreader.js file to start editing the test suites.

About the tests

Here are the other test suites written in Jasmine.js by Millie Lin.

Test Suite "The Menu"

By inspecting the menu toggle events in Chrome dev tools, I found the program show and hide the slide menu by toggling class 'menu-hidden' on .

By default, the body should be with class menu-hidden. By using jQuery to select the BODY element and get the class with attr. So that the test should detect if the body tag contains 'menu-hidden' to check if the toggleClass function runs properly.

The click() event is used to check if the 'menu-hidden' class exists to ensure the function goes well.

Test Suite "Initial Entries"

In app.js, it runs loadFeed() to load the data from each feed. If the feed load successfully, it will render the HTML inside the feed container DIV.feed.

Since .entry is an rendered element when feed successfully initialised, by checking if the .feed HTML after loading can see if the entries has been loaded properly.

The loadFeed() is asynchronous so that the test should run beforeEach() and done() to ensure the loadFeed() runs in the test.

By calling loadFeed(0, function(...)) the test load the first feed which contains initial entries for detection.

Test Wuite "New Feed Selection"

There are more than one feed in the allFeeds. The loadFeed() function load specified feed with the id(index).

The second feed content should be different from the first feed. So that by comparing the rendered HTML content, we can check if the program loads a different feed with the function instead the same one.

The HTML can be get in jQuery .html() function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.