We may earn an affiliate commission when you visit our partners.
Course image
Juan Lizarazo and Reynaldo Pena

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a Document Object Model (DOM), and it has a clean, obvious syntax so that you can easily write tests.

Read more

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a Document Object Model (DOM), and it has a clean, obvious syntax so that you can easily write tests.

If you want to stand out as a JavaScript developer, you need to learn how to unit test your code. Jasmine is a great way to do so.

By the end of watching this course, you'll be able to:

  • Understand what unit testing is and why it is important in today's market.

  • Set up jasmine from scratch.

  • Write clean and concise suites, specs, and specifications.

  • Understand and use all of the out-of-the-box jasmine matchers, create your custom ones, and include them in your project.

  • Isolate dependencies through test-doubles, known as spies in Jasmine, for true unit testing.

  • Unit test asynchronous code.

  • Setup test reports and continuous integration from version control to automate your test runs.

  • Apply best practices when structuring your tests.

With this course, you'll get downloadable source code, slides, and section notes.

No previous unit testing experience is needed, just basic familiarity with JavaScript, HTML, and CSS (just optional when building our course project).

You don't need previous experience with a testing framework at all. We've got you covered.

Promo video music license:

Adventures by A Himitsu - Creative Commons — Attribution 3.0 Unported— CC BY 3.0   Music released by Argofox - Music provided by Audio Library   

Enroll now

What's inside

Learning objectives

  • Write clean suites, specs and expectations.
  • Isolate dependencies on units through test doubles (spies).
  • Automate test runs through continuous integration from version control using a headless browser and a test runner.
  • Set up jasmine as their unit testing framework from scratch.
  • Configure setup and teardown for suites.
  • Understand how matchers work in jasmine.
  • Write custom matchers and include them in your project.
  • Consume third party matchers.
  • Test asynchronous code.
  • Run unit tests both from a web browser and from a terminal through a test runner.
  • Generate code coverage reports.
  • Improve dependency management through a package manager.
  • Show more
  • Show less

Syllabus

Explore the course outline and get familiar with Unit testing and the jasmine framework. Additionally, download the course materials.

Here we explore the full course outline.

Read more

Here we explore the importance of unit testing and why Jasmine as your testing framework is a great choice.

Important javascript notes!
Download exercise files

Here we write our first spec using jasmine, from scratch!

Recap of what we learned in this section.

Downloadable materials for this section.

Setup the course project and understand and use the different jasmine functions by using them on real code.

Overview of the content for this section.

Explore the project we will build and that we will unit test throughout this course.

Build the course project base functionality.

Program the user interface to interact with the core functionality we previously built so the project is usable.

Enhance the error handling for our application.

Make our application more attractive to the user and improve user experience.

Manually set up jasmine from the main jasmine repository.

Explore what suites are, and how to implement them, to test our application.

Understand what specs are, how to use them and we will write the first specs that test our application.

Learn about expectations and write our own to assert our code.

In this lecture we are going to learn how to disable suits and specs, and why is this useful.

Downloadable materials of this section.

Understand and use the different matchers jasmine offers to write great assertions on your code. Also write your own matchers or include them from third party sources.

Learn what a matcher is, and how to use them.

Learn about the toBe matcher and use it to test your code.

Learn how to use the toEqual matcher and use it to test our code.

Learn how to use the toBeTruthy, and toBeFalsy matchers, why they are important and use them to test our code.

Learn  how to negate the different matchers and use this to test our code.

Learn about the toBeDefined, and the toBeUndefined matchers, and use them to test your code.

Learn about the toBeNull matcher, and use it to test your code.

Learn about the toContain matcher, and use it to test your code.

In this lecture we will learn about the toBeNaN matcher, and use it to test our code.

Learn about the toThrow, and toThrowError matchers, and use it to test our code.

Learn about the toMatch matcher, and use it to test your code.

Learn about other  matchers, and use it to test your code.

Explore asymmetric matchers and learn how to match anything.

Create our own custom matchers to fit the needs of our code.

Update on third party matchers! Read before the next lecture.

Explore the different matchers from third-party sources.

Recap what we learned in this section.

Section notes
Better organize your specs by applying best practices.

Overview of the content of this section.

Some recommendations and best practices to organize better your specs.

Explore how to nest our suites and why this is important.

Explore the different life cycle hooks that jasmine offers.

Learn about the beforeEach and the afterEach setup and teardown methods and use them in your suites.

Learn about the beforeAll, and the afterAll life cycles, and use them to test in your suites.

Learn about the this  keyword, and the different context that it has in our suites.

Spy on your code to isolate dependencies for true unit testing. Assert calls and arguments on dependencies.

Learn what spies are, why they are important and how to use them.

Explore the different functions that jasmine has to spy on our code.

Learn about the toHaveBeenCalled matcher, and use it to write assertions on spies.

Learn about the toHaveBeenCalledWith matcher, , and use it to write assertions on spies.

Learn about the toHaveBeenCalledTimes matcher, and use it to write assertions on spies.

Learn how to spy on JavaScript prototypes.

Learn about the spy method callThrough and use it to configure your spies.

Learn about callFake and use it to configure your spies.

Learn about the spy method returnValue and use it to configure your spies.

Learn about returnValues and use it to configure your spies.

Learn about throwError and use it to configure your spies.

In this lecture we implement a getter for our project.

Learn about how to test getters and setters with spyOnProperty

Use jasmine with asynchronous code.

Use promises within our application.

The done callback provided by jasmine to test promises.

Your turn to work on a spec!

Solution for the exercise, and the logic behind it.

Async and await, we implement it in our application and show you how to test with them.

Generate test reports and integrate with CI systems. Better manage external dependencies and automate test discovery with a test runner.

The package.json, how it works and how to generate one.

Install the different dependencies needed for the application.

Karma runner, the benefits and how to use it to automatize our tests.

What is a headless browser, and add one to our Karma runner.

What are coverage reports, how to read them and why are they important.

Push our code to version control.

Connect our repository to the CI system.

Create the manifest to build our project for the CI system.

Add a build badge for our README in our repository.

Here we cover some topics that you should explore next for further learning.

Explore what you should learn next to further improve your skills.

Bonus!

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Useful for front-end developers and JavaScript professionals to improve their skills in unit testing
Covers fundamental and advanced concepts of unit testing, providing a strong foundation for learners
Instructors have a combined 15+ years of experience in web development and training
In-depth exploration of matchers, spies, and other techniques for writing effective unit tests
Provides practical examples and exercises to reinforce learning and understanding
Includes downloadable materials, such as code samples and slides, for enhanced learning
Suitable for beginners with basic familiarity with JavaScript but also valuable for experienced developers looking to enhance their unit testing skills

Save this course

Save Unit testing your Javascript with jasmine to your list so you can find it easily later:
Save

Reviews summary

Jasmine testing framework in javascript

Learners say Jasmine testing framework is explained clearly and simply. The instructor demonstrates its functionality, configuration, matches, and usage. Accordingly, learners say that understanding and learning the framework is easy.
Easy to understand and learn.
"Since it's explained in a very simple way, it's easy to understand and learn."
Instructor provides clear explanations.
"The instructor clearly explains the functionality of the Jasmine testing framework, its configuration, matches and usage."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Unit testing your Javascript with jasmine with these activities:
Test asynchronous code with Jasmine
Testing asynchronous code ensures your application behaves as expected in a non-blocking environment.
Browse courses on Asynchronous Testing
Show steps
  • Read the Jasmine documentation on asynchronous testing.
  • Implement a test for a function that returns a promise.
  • Implement a test for a function that uses async/await.
Build a Jasmine testing framework for a real-world project
Applying Jasmine to a practical project will solidify your understanding and demonstrate your proficiency.
Show steps
  • Identify a suitable open-source project or create your own.
  • Design and implement a Jasmine testing framework for the project.
  • Write comprehensive tests for key functionalities.
  • Contribute your testing framework to the project or share it publicly.
Show all two activities

Career center

Learners who complete Unit testing your Javascript with jasmine will develop knowledge and skills that may be useful to these careers:
Software Engineer
A **Software Engineer** designs, develops, and maintains software applications. This course will introduce you to the fundamentals of software development, including the principles of software design, coding, testing, and debugging. You will also learn about different programming languages and software development tools. This course will help you build a strong foundation in software development and prepare you for a career as a Software Engineer.
Web Developer
A **Web Developer** designs, develops, and maintains websites. This course will introduce you to the fundamentals of web development, including the principles of web design, HTML, CSS, and JavaScript. You will also learn about different web development tools and technologies. This course will help you build a strong foundation in web development and prepare you for a career as a Web Developer.
Test Engineer
A **Test Engineer** is responsible for designing, developing, and executing test plans to ensure that software products meet the required standards. This course will introduce you to the principles of software testing, including test planning, test execution, and test reporting. You will also learn about different testing tools and techniques. This course will help you build a strong foundation in software testing and prepare you for a career as a Test Engineer.
Software Tester
A **Software Tester** is responsible for testing and evaluating software products to ensure that they meet the required standards. This course will introduce you to the principles of software testing, including test planning, test execution, and test reporting. You will also learn about different testing tools and techniques. This course will help you build a strong foundation in software testing and prepare you for a career as a Software Tester.
Quality Assurance Analyst
A **Quality Assurance Analyst** is responsible for testing and evaluating software products to ensure that they meet the required standards. This course will introduce you to the principles of software testing, including test planning, test execution, and test reporting. You will also learn about different testing tools and techniques. This course will help you build a strong foundation in software testing and prepare you for a career as a Quality Assurance Analyst.
Product Manager
A **Product Manager** is responsible for managing the development and launch of new products. This course will introduce you to the principles of product management, including product planning, product development, and product launch. You will also learn about different product management tools and techniques. This course will help you build a strong foundation in product management and prepare you for a career as a Product Manager.
Business Analyst
A **Business Analyst** is responsible for analyzing business requirements and developing solutions to meet those requirements. This course will introduce you to the principles of business analysis, including requirements gathering, requirements analysis, and solution design. You will also learn about different business analysis tools and techniques. This course will help you build a strong foundation in business analysis and prepare you for a career as a Business Analyst.
Project Manager
A **Project Manager** is responsible for planning, executing, and closing projects. This course will introduce you to the principles of project management, including project planning, project execution, and project closure. You will also learn about different project management tools and techniques. This course will help you build a strong foundation in project management and prepare you for a career as a Project Manager.
Technical Writer
A **Technical Writer** is responsible for creating technical documentation for software products. This course will introduce you to the principles of technical writing, including technical writing style, technical writing tools, and technical writing techniques. You will also learn about different types of technical documentation. This course will help you build a strong foundation in technical writing and prepare you for a career as a Technical Writer.
UX Designer
A **UX Designer** is responsible for designing the user experience for software products. This course will introduce you to the principles of UX design, including user research, user interface design, and user testing. You will also learn about different UX design tools and techniques. This course will help you build a strong foundation in UX design and prepare you for a career as a UX Designer.
Data Analyst
A **Data Analyst** is responsible for collecting, analyzing, and interpreting data to identify trends and patterns. This course will introduce you to the principles of data analysis, including data collection, data analysis, and data interpretation. You will also learn about different data analysis tools and techniques. This course will help you build a strong foundation in data analysis and prepare you for a career as a Data Analyst.
Software Architect
A **Software Architect** is responsible for designing, developing, and maintaining the architecture of software systems. This course will introduce you to the principles of software architecture, including software architecture design, software architecture development, and software architecture maintenance. You will also learn about different software architecture tools and techniques. This course will help you build a strong foundation in software architecture and prepare you for a career as a Software Architect.
Developer Advocate
A **Developer Advocate** is responsible for promoting and evangelizing the use of software products and technologies. This course will introduce you to the principles of developer advocacy, including developer relations, developer marketing, and developer education. You will also learn about different developer advocacy tools and techniques. This course will help you build a strong foundation in developer advocacy and prepare you for a career as a Developer Advocate.
IT Manager
An **IT Manager** is responsible for planning, managing, and evaluating an organization's information technology (IT) resources. This course will introduce you to the principles of IT management, including IT planning, IT management, and IT evaluation. You will also learn about different IT management tools and techniques. This course will help you build a strong foundation in IT management and prepare you for a career as an IT Manager.
Product Owner
A **Product Owner** is responsible for managing the development and launch of new products. This course will introduce you to the principles of product management, including product planning, product development, and product launch. You will also learn about different product management tools and techniques. This course will help you build a strong foundation in product management and prepare you for a career as a Product Owner.

Reading list

We've selected seven books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Unit testing your Javascript with jasmine.
The Art of Unit Testing classic book on unit testing that covers the principles and practices of unit testing in general. It great resource for anyone who wants to learn more about unit testing, regardless of the language or framework they are using.
JavaScript Testing Patterns collection of patterns for unit testing JavaScript code. It covers a wide range of topics, including how to test asynchronous code, how to mock dependencies, and how to write effective test cases.
Unit Testing for Beginners free online course that teaches the basics of unit testing. It covers everything from the basics of unit testing to advanced topics like mocking and asynchronous testing.
Jasmine Tutorial free online tutorial that teaches how to unit test JavaScript code with Jasmine. It covers a wide range of topics, including how to write effective test cases, how to mock dependencies, and how to use Jasmine with other testing tools.
Jasmine Cookbook collection of recipes for unit testing JavaScript code with Jasmine. It covers a wide range of topics, including how to write effective test cases, how to mock dependencies, and how to use Jasmine with other testing tools.
Jasmine Reference comprehensive reference guide for unit testing JavaScript code with Jasmine. It covers everything from the basics of Jasmine to advanced topics like mocking and asynchronous testing.
Jasmine Best Practices collection of best practices for unit testing JavaScript code with Jasmine. It covers everything from how to write effective test cases to how to organize your test code.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Here are nine courses similar to Unit testing your Javascript with jasmine.
Testing JavaScript with Jasmine 2 and TypeScript
Most relevant
Learn Protractor(Angular Testing) from scratch +Framework
Most relevant
Learn Unit Testing with NUnit and C#
Most relevant
Backend Development with Node.js
Most relevant
JavaScript Testing
Most relevant
Getting Started Unit Testing with JUnit 5
Most relevant
WPF and MVVM: Test Driven Development of ViewModels
Most relevant
JavaScript Unit Testing - The Practical Guide
Most relevant
JavaScript Unit Testing with Jest
Most relevant
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2024 OpenCourser