Selecting Jasmine: Justification for JavaScript Testing Framework in Team Project

Categories: EngineeringScience

Abstract

Software testing aimed at evaluating an attribute or capability of a program to determine that it meets its preset requirements. With the dominance of JavaScript in web and mobile development, there are an abundance of excellence JavaScript testing framework to help developers to better test the application. This study intends to justify the use of Jasmine over other alternative JavaScript testing framework in the market. Jasmine and two other well-known alternative framework are compared to find out the factors that lead us to consider Jasmine as the main testing framework for the Team Project.

Introduction

My team, Team Tutum, is working on an Android application for our 4th year Team Project.

Service Loop is a mobile platform where students can share and trade their skills with one another. The goal of this app is to facilitate exchanges of services such as guitar lessons in exchange for personal training lessons. Our app provided a forum, where users can advertise offers and negotiate exchanges with other users.

Get quality help now
WriterBelle
WriterBelle
checked Verified writer

Proficient in: Engineering

star star star star 4.7 (657)

“ Really polite, and a great writer! Task done as described and better, responded to all my questions promptly too! ”

avatar avatar avatar
+84 relevant experts are online
Hire writer

The highlight of this app is the offer of strong security system in place, such as contract and receipt generation combined with the use of digital signature.

As the app’s main target users are students, we are aiming to make our app’s user interface simple and intuitive. The main technology that the app is using is JavaScript and Ionic framework for frontend, NodeJS for backend and MongoDB as the database. The app is built on CordovaPhoneGap platform, which wraps the HTML/JavaScript codes into a native container that can access device functions of Android platform, using plugins.

My Roles and Challenges

My role within the team for the Team Project is software tester and scrum master.

Get to Know The Price Estimate For Your Paper
Topic
Number of pages
Email Invalid email

By clicking “Check Writers’ Offers”, you agree to our terms of service and privacy policy. We’ll occasionally send you promo and account related email

"You must agree to out terms of services and privacy policy"
Write my paper

You won’t be charged yet!

One of the roles of software tester is learned to think from user’s perspective, identify use cases that the app can be test on. Team Project uses agile software development, and agile testing is a software testing process where it is continuous rather than sequential. As a tester, I worked together with teammates who are responsible with programming the app to create acceptance test for each feature.

I am responsible for using decision tables to create test cases, following black box testing methodology. In this test-driven development environment, test cases were written before functions to ensure minimum defect rates. Unit testing is done by programmers and I provided assistance whenever needed. When the features are tested, I am responsible for integration testing to make sure all functionality works together.

The application will be written with Cordova development framework, with frontend comprised with JavaScript and Ionic styles, and NodeJS for backend. There are several criteria to consider when choosing a suitable testing framework:

  1. Difficulty
  2. Assertions
  3. BDD/TDD friendly
  4. Asynchronous testing
  5. Visual Testing
  6. Code Coverage
  7. App Language
  8. Community Support

The first challenge faced at the very beginning of the project is to choose a suitable testing framework for JavaScript. If the testing framework did not meet our criteria, it will slow down the testing process and overall delay the whole sprint.

General Literature

Software testing is conducted to check whether the actual results match the expected results and ensure that the software system is defect free. It also helps identify any errors, gaps or missing criteria and requirements. There are several levels of software testing to be considered.

Unit Testing is a level of software testing where individual units of a software is tested. The purpose of the test is to make sure the unit performs as designed. Unit testing is usually the first level of software testing before integration testing. As in agile testing environment, the developers themselves write the unit tests. The benefits of conducting Unit Testing including easier debugging, reliable code, faster development, reusable codes etc. [13]

Integration Testing is a level of testing where individual units are combined and tested as a group. The purpose of the test is to expose any faults in the interaction between integrated units. [13]

Acceptance Test is to evaluate the system’s compliance with the business requirements and user needs and determine if it is ready for use in real world. The tests are conducted under combined efforts by programmers, testers and customers. [14]

The definition of done will include the above three level of testing. A functionality has to pass all tests and accepted by both developers and testers before moving on to the next functionality. The development process will follow TDD, while using BDD to assist with creating user stories in Scrum.

Test-Driven Development(TDD) is a software development technique that involves writing automated test cases before writing functional codes. User stories need to be developed in every sprint, under cooperation of both developers and coders. Within the tasks in the user stories, test cases need to be created first before any coding can began, using equivalence value table and boundary value to make sure that all aspect of the test cases are tested. The developers make sure that their functional codes passed all test cases before proceeding to another functionality. This technique drives shippable product at the end of a sprint. [12]

Evolved from TDD, Behaviour-Driven Development(BDD) defines user behavior before writing test or codes. In BDD, user behavior is defined and written in simple English. These are then converted to automated scripts to run against functional code. The developers make sure their codes passed the written test script at the end of the sprint. BDD has the benefits of explaining behavior of an application for the end users while TDD only focus on how functionality is implemented. BDD also ensure all stakeholders to be on the same page with requirement, which means it is easier to pass acceptance test. [12]

Specific Literature

The research for this topic is mainly done on Internet, using Google as primary search engine. Focuses have been put on well-known tech websites such Medium, Stack Overflow that provides in-depth analysis of various testing frameworks, the respective testing frameworks GitHub IO websites for technical manuals, and statistical websites such as stateofjs.com. After the research, I have narrowed down my choice of testing framework into three testing framework, based on their popularity in terms of usage, level of satisfactory among the developers [10]and compatibility with my defined criteria. The testing frameworks mentioned above are Jasmine, Mocha and Jest.

Jasmine [4] was created around 2008, as one of the oldest JavaScript testing framework. Created for BDD testing, Jasmine can also be used for TDD testing. Jasmine is easier to get started, it was built to be easy to set up and use in almost scenario. Jasmine provides everything out-of-the-box, including assertions, spies, and mocks. Jasmine can run with test runner like Karma to print the results automatically in the browser, but the standalone version is just as easy to use and setup with. Jasmine included global, which means that it is easy to start adding tests right away. Since Jasmine has been around for long time, there are plenty of documentation and resources online to reference with. [9]

Mocha [8] was created around 2011 for BDD testing. It is open source and very flexible library providing testers and developers with just basic test structure. Functionality for assertions, spies and mocks needed to be add via other libraries. For example, Chai, one of the most popular open-source assertion libraries and Sinon, a popular mocking and spy library. This means that Mocha will take longer if not little harder to set up than others. However, Mocha only needs to set up once and it is good to go. Mocha also included test structure as globals, but the plugin will require to include them anyway. [9]Mocha has the same describe test suite and it function as Jasmine. However, since it does not have built int assertion library, developers must use dedicated assertion library such as Chai.

Jest [5] was developed by Facebook and used by it internally. It is rated as number one JavaScript automation testing framework in 2018 by StateOfJS survey. Jest was based on Jasmine originally, although Facebook replaced most of its functionality and added new features on top of it. It was developed for testing React apps, but it can also be used on different JavaScript library. Like Jasmine, Jest requires minimal configuration out-of-the-box as it comes with mocking and assertion support. The test cases can be written with BDD approach, but it supported TDD too. Jest is well documented, and provides features such as snapshot testing and code coverage built in. However, Jest has considerably steep learning curve especially for newcomers. [9]

Proposed Solution

Table 4. Comparison of Jasmine, Mocha and Jest
Jasmine Mocha Jest
Difficulty Elegant programming style and patterns. Easy to use. Similar to Jasmine but takes longer time to setup and maintain. Steep learning curve for newcomers but has good performance.
Assertions Included. No. Can be added via libraries, such as Sinon. Included.
BDD/TDD Friendly Yes Yes Yes
Asynchronous Testing Supported Supported Supported
Visual Testing Yes, with jasmine-snapshot library Yes, with mocha-visual-test library Yes, including Snapshot Testing
Code Coverage Not included, can be added using Istanbul tool. Included. Included.
App Language Support any JavaScript framework, especially NodeJS Support any JavaScript framework, especially NodeJS Mainly React, but easily integrate with other JavaScript framework.
Community Support Well documented. Well documented.

Developed by Facebook, updated regularly with new features.

Objectively, based on the data gathered above, Jest or Mocha are good choice of testing framework. Mocha’s strong point is flexibility, and Jest is strong with fast performance and new features, both are more popular than Jasmine in the market today. However, based on this team project’s requirements, I determined that Jasmine is much more suitable as the main JavaScript testing framework.

Jasmine is easy to use with logical styles and patterns, which is suitable for a new learner of JavaScript like me. Jasmine also included tools that I needed right out of the box, such as assertion, mocks and spies. Additional tools can be added such as Istanbul for code coverage. Jasmine also supported asynchronous testing, which is very important as there are several proposed features in the app that will be running async functions. As one of the oldest JavaScript testing framework, there are plenty of documentation online, from official Jasmine documentation, StackOverflow to various technical websites, Jasmine has strong online resources, which is extremely helpful.

Evaluate Proposed Solution

As of writing this research paper, there are no complete functions to be tested yet. However, I have successfully set up the Jasmine testing environment for unit testing. I also integrated the Istanbul library for code coverage. I have created an example class “Person” with separate functions within the class to test with.

I can use “npm test” command to commence the unit testing and “npm run coverage” for code coverage generation.

As the tester, I make sure that everyone on the team understand the testing process and how Jasmine test codes would be written. It is my responsibility to provide guidance when there is difficulty with unit testing for their codes.

Following the TDD methodology, I wrote test cases and then the developers would create the functionality codes design to pass my tests.

Conclusion

Choosing a suitable testing framework is important as it sets out how the testing process will be in the development process. If the chosen testing framework did not meet the criteria, it will slow down the testing and the overall development of the application. It is important that the framework meets the predefined criteria to ensure a smooth testing process and produce a defect free application.

References

  1.  Ben (2017). JavaScript unit testing frameworks: Comparing Jasmine, Mocha, AVA, Tape and Jest [2018]. [online] Raygun Blog. Available at: https://raygun.com/blog/javascript-unit-testing-frameworks/ [Accessed 29 Nov. 2019].
  2. Codementor Team (2016). JavaScript Testing Framework Comparison: Jasmine vs Mocha. [online] Codementor.io. Available at: https://www.codementor.io/codementorteam/javascript-testing-framework-comparison-jasmine-vs-mocha-8s9k27za3 [Accessed 29 Nov. 2019].
  3. CristianGiagante (2019). Jasmine vs Jest vs Mocha | What are the differences? [online] StackShare. Available at: https://stackshare.io/stackups/jasmine-vs-jest-vs-mocha [Accessed 29 Nov. 2019].
  4. Jasmine (2013). Your_first_suite. [online] Available at: https://jasmine.github.io/tutorials/your_first_suite [Accessed 29 Nov. 2019].
  5. estjs.io. (2017). Jest · Delightful JavaScript Testing. [online] Available at: https://jestjs.io/en/ [Accessed 29 Nov. 2019].
  6. Knight, A. (2018). JavaScript Testing with Jasmine. [online] Automation Panda. Available at: https://automationpanda.com/2018/01/26/javascript-testing-with-jasmine/ [Accessed 29 Nov. 2019].
  7. Lostechies.com. (2012). JavaScript Unit Tests: Jasmine vs Mocha · Los Techies. [online] Available at: https://lostechies.com/derickbailey/2012/11/01/javascript-unit-tests-jasmine-vs-mocha/ [Accessed 29 Nov. 2019].
  8. Mochajs.org. (2019). Mocha - the fun, simple, flexible JavaScript test framework. [online] Available at: https://mochajs.org/ [Accessed 29 Nov. 2019].
  9. Roy, A. (2019). Top Eight JavaScript Automation Testing Frameworks In 2019 - DZone Web Dev. [online] dzone.com. Available at: https://dzone.com/articles/top-8-javascript-automation-testing-frameworks-in [Accessed 29 Nov. 2019].
  10. Stateofjs.com. (2018). The State of JavaScript 2018: Testing - Overview. [online] Available at: https://2018.stateofjs.com/testing/overview/ [Accessed 29 Nov. 2019].
  11. Swersky, D. (2018). Mocha vs Jasmine, Chai, Sinon & Cucumber in 2019. [online] Raygun Blog. Available at: https://raygun.com/blog/mocha-vs-jasmine-chai-sinon-cucumber/ [Accessed 29 Nov. 2019].
  12. Nair, Jithin. “TDD vs BDD - What’s the Difference Between TDD and BDD? - TestLodge Blog.” TestLodge Blog, 18 Apr. 2018, blog.testlodge.com/tdd-vs-bdd/. Accessed 29 Nov. 2019.
  13. “Unit Test vs Integration Test: What’s the Difference?” Guru99.Com, 20 Nov. 2019, www.guru99.com/unit-test-vs-integration-test.html. Accessed 29 Nov. 2019.
  14. “Acceptance Testing - Software Testing Fundamentals.” Software Testing Fundamentals, 3 Mar. 2018, softwaretestingfundamentals.com/acceptance-testing/.
Updated: Feb 19, 2024
Cite this page

Selecting Jasmine: Justification for JavaScript Testing Framework in Team Project. (2024, Feb 19). Retrieved from https://studymoose.com/document/selecting-jasmine-justification-for-javascript-testing-framework-in-team-project

Live chat  with support 24/7

👋 Hi! I’m your smart assistant Amy!

Don’t know where to start? Type your requirements and I’ll connect you to an academic expert within 3 minutes.

get help with your assignment