We may earn an affiliate commission when you visit our partners.
Course image
Academind by Maximilian Schwarzmüller and Maximilian Schwarzmüller

Automated testing is a key concept in modern (web) development.

It is a concept that can be intimidating at first, hence many developers shy away from diving into testing and adding tests to their projects.

This course teaches you automated unit & integration testing with JavaScript from the ground up. You will learn how tests are written and added to your projects, what should (and should not) be tested and how you can test both simple as well as more complex code.

Read more

Automated testing is a key concept in modern (web) development.

It is a concept that can be intimidating at first, hence many developers shy away from diving into testing and adding tests to their projects.

This course teaches you automated unit & integration testing with JavaScript from the ground up. You will learn how tests are written and added to your projects, what should (and should not) be tested and how you can test both simple as well as more complex code.

You will learn about the software and setup required to write automated tests and example projects will be provided as part of the course. It's a hands-on, practical course, hence you won't get stuck in theory - instead you'll be able to learn all key concepts at real examples.

In the course, Vitest will be used as the main testing library & tool. It's a modern JavaScript test runner and assertion library that provides Jest compatibility. Hence what you'll learn in this course will help you no matter if you're working with Vitest or Jest. And the core concepts will apply, no matter which testing setup you're using at all.

As part of this course, typical testing problems will be defined and solved and common strategies like mocking or working with spies are taught in great detail. This course also does not focus on specific types of JavaScript projects - neither does it focus on any specific library or framework.

Instead, you'll learn how to automatically test your (vanilla) JavaScript code, no matter if it's a NodeJS or frontend project. The fundamentals you'll gain in this course will help you in all your future projects - backend (NodeJS) and frontend (vanilla JS, React, Vue, Angular) alike.

This course will provide you with an extremely solid foundation to build up on, such that you can start adding tests to all your JavaScript projects.

In detail, this course will teach you:

  • What exactly "testing" or "automated testing" is (and why you need it)

  • What "unit testing" is specifically

  • Which tools you need to enable automated unit tests in your projects

  • How to write unit tests

  • How to get started with integration tests

  • How to formulate different expectations (assertions)

  • Which patterns to follow when writing tests

  • How to test asynchronous and synchronous code

  • How to deal with side effects with help of spies & mocks

  • How to apply all these concepts in real projects & examples

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • Write and structure unit & integration tests
  • Remove side effects from tests via mocking and spies
  • Work with popular javascript test runners and libraries
  • Write good tests and focus on testing core business logic

Syllabus

Learn what unit & integration testing is exactly and what this course has to offer for you!
Welcome To This Course!
What Is Testing?
Unit Testing: What & Why?
Read more
Unit vs Integration vs E2E Tests
A Quick Note About Test-Driven Development (TDD)
About This Course
Join Our Learning Community
Course Resources & Project Snapshots
Learn about the setup required to integrate automated tests into your projects. You'll learn about testing libraries, test runners & assertion libraries and which roles these "things" play.
Module Introduction
Which Tools Are Needed For Testing?
Jest & Vitest
Installing Vitest
Course Project Setup
Learn about the key testing fundamentals. Learn how tests are added to a project, how two write tests and which logic should go into your unit testing code.
Basic Test File & Project Setup
Writing a First Test
Running Tests
Why Are We Testing?
The AAA Pattern - Arrange, Act, Assert
Keep Your Tests Simple!
Defining Behaviors & Fixing Errors In Your Code
Demo: Writing More Tests
Testing For Errors
Demo: Adding More Tests
Testing For Thrown Errors & Error Messages
Exercise: Problem
Exercise: Solution
Tests With Multiple Assertions (Multiple Expectations)
More Practice!
Introducing Test Suites
Adding Tests To Frontend & Backend Projects
Module Summary
Learn what it takes to write good tests and how to test the right things.
What To Test & Not To Test
Writing Good Tests - An Overview & Summary
Only Test "One Thing"
Splitting Functions For Easier Testing & Better Code
Refactoring Code
Formulating Different Expectations
A Word About Code Coverage
Learn what exactly integration tests are, how they differ from unit tests and how to write + run them.
Introducing Integration Tests
Writing an Integration Test & Reasoning
Integration vs Unit Tests: Finding the Right Balance
Time to dive deeper into testing and explore some advanced testing concepts and features!
toBe() vs toEqual()
The Problem With Asynchronous Code
Testing Asynchronous Code With Callbacks
Testing Asynchronous Code With Promises & async / await
Returning Promises In Tests
Getting Started with "Testing Hooks"
Why Hooks?
Using Testing Hooks (beforeEach, beforeAll, afterEach, afterAll)
Concurrent Tests
Concurrency & Default Behavior
Learn what side effects are, which problems they can cause and how you can work around them with mocks and spies (and of course what "mocks and spies" actually are).
The Starting Project
The Problem With Side Effects & Tests
Introducing Spies & Mocks
Working with Spies
Getting Started with Mocks & Automocking
Note on Mocking
Notes on Spies
Custom Mocking Logic
Managing Custom Mock Implementations Globally (__mocks__ Folder)
More Mocking Functionalities
Let's dive a bit deeper into mocking and core mocking functionalities and concepts.
Refresher: Practicing Basic Tests (1)
Refresher: Practicing Basic Tests (2)
Reasons to Mock
Mocking Global Values & Functions
Mocking Frontend Libraries
Test-specific Mocking Logic
Mocking In Selected Places
Using Local Mock Values
Learn how to write tests that need to interact with the browser DOM.
Understanding the Problem
Working with Different Testing Environments
Setting up a Virtual HTML Page
Testing DOM Functionalities
DOM Tests & Cleanup Work
Finishing Example
A Brief Look at the "Testing Library" Package
You did it! You completed the course - great job!

Good to know

Know what's good
, what to watch for
, and possible dealbreakers
Taught by Maximilian Schwarzmüller, founder of Academind, who is a respected creator of programming courses
Develops skills in JavaScript testing, which is highly relevant in web development and programming
Suitable for beginners, as it builds a solid foundation in JavaScript testing from the ground up
Provides hands-on, practical learning through example projects and interactive materials
Covers advanced testing concepts such as mocking and spying, which are essential for effective testing
May require students to have some prior understanding of JavaScript, as it assumes some familiarity with the language

Save this course

Save JavaScript Unit Testing - The Practical Guide to your list so you can find it easily later:
Save

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 JavaScript Unit Testing - The Practical Guide with these activities:
Create a JavaScript resource collection
Organize and consolidate useful JavaScript resources, including tutorials, articles, and code snippets, for easy access and future reference.
Show steps
  • Gather resources related to JavaScript concepts and technologies
  • Categorize and organize the resources
  • Create a central repository or document to store the collection
Connect with experienced JavaScript developers
Seek guidance and support from experienced professionals in the field, gaining valuable insights and learning from their expertise.
Show steps
  • Join online communities or forums related to JavaScript
  • Attend meetups or workshops where you can meet JavaScript developers
  • Reach out to potential mentors and ask for their guidance
Review basic JavaScript concepts
Reinforce the foundational understanding of JavaScript programming principles and syntax, preparing you for the more advanced concepts explored in the course.
Show steps
  • Review variable declaration and data types
  • Practice writing simple JavaScript functions
  • Experiment with manipulating DOM elements using JavaScript
Six other activities
Expand to see all activities and additional details
Show all nine activities
Engage in peer-to-peer learning sessions
Collaborate with fellow students, share knowledge, and clarify concepts through peer-to-peer learning sessions.
Show steps
  • Form a study group with classmates
  • Meet regularly to discuss course material, solve problems, and quiz each other
  • Provide support and encouragement to each other
Solve coding challenges on LeetCode
Enhance your problem-solving skills and deepen your understanding of JavaScript by tackling coding challenges on platforms like LeetCode.
Show steps
  • Choose a challenge that aligns with the concepts covered in the course
  • Analyze the problem and design a solution
  • Implement your solution in JavaScript and test it thoroughly
Follow online tutorials on advanced JavaScript topics
Expand your knowledge by exploring advanced JavaScript concepts through guided tutorials, broadening your understanding and skills.
Show steps
  • Identify a specific topic you want to deepen your understanding of
  • Find reputable online tutorials or courses that cover the topic
  • Follow the tutorials, taking notes and practicing the concepts
Build a simple JavaScript project
Apply your newfound knowledge to a practical project, solidifying your understanding and showcasing your skills in JavaScript programming.
Show steps
  • Identify a project idea that aligns with your interests
  • Design the project architecture and components
  • Develop the project using JavaScript
  • Test and debug your project thoroughly
Participate in JavaScript hackathons or competitions
Challenge yourself by participating in JavaScript hackathons or competitions, showcasing your skills and learning from others.
Show steps
  • Identify JavaScript hackathons or competitions that align with your interests
  • Form a team or participate individually
  • Develop a solution to the challenge
Contribute to JavaScript open-source projects
Gain practical experience and contribute to the JavaScript community by participating in open-source projects, enhancing your skills and knowledge.
Show steps
  • Identify JavaScript open-source projects that align with your interests
  • Review the project documentation and codebase
  • Contribute fixes, enhancements, or new features to the project

Career center

Learners who complete JavaScript Unit Testing - The Practical Guide will develop knowledge and skills that may be useful to these careers:
DevOps Engineer
DevOps Engineers are responsible for bridging the gap between development and operations teams. They work with a variety of tools and techniques to automate the build, deployment, and testing of software applications. This course can help you learn how to write tests for a variety of software applications, which is essential for ensuring that your software is free of defects and meets the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Test Automation Engineer
Test Automation Engineers are responsible for automating the testing of software applications. They work with a variety of testing tools and techniques to create automated tests that can be used to test software applications for both functional and non-functional requirements. This course can help you learn how to write tests for a variety of software applications, which is essential for ensuring that your software is free of defects and meets the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Quality Assurance Analyst
Quality Assurance Analysts are responsible for ensuring that software applications meet the needs of their users and are free of defects. They work with a variety of testing tools and techniques to test software applications for both functional and non-functional requirements. This course can help you learn how to write tests for a variety of software applications, which is essential for ensuring that your software is free of defects and meets the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Software Tester
Software Testers are responsible for testing software applications to identify defects and ensure that they meet the needs of their users. They work with a variety of testing tools and techniques to test software applications for both functional and non-functional requirements. This course can help you learn how to write tests for a variety of software applications, which is essential for ensuring that your software is free of defects and meets the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Product Manager
Product Managers are responsible for defining the vision and roadmap for software products. They work with a variety of stakeholders, including developers, testers, and business analysts, to ensure that software products meet the needs of their users. This course can help you learn how to write tests for a variety of software applications, which is essential for ensuring that your software is free of defects and meets the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Software Engineer
As a Software Engineer, you will write and maintain code for a variety of software applications. Many Software Engineers choose to specialize in a particular area, such as web development, mobile development, or data science. This course can help you build a strong foundation in software testing, which is an essential skill for any Software Engineer. By learning how to write and run tests, you can help ensure that your software is free of defects and meets the needs of your users.
Software Development Manager
Software Development Managers are responsible for leading and managing software development teams. They work with a variety of stakeholders, including developers, testers, and business analysts, to ensure that software development projects are completed on time and within budget. This course can help you learn how to write tests for a variety of software applications, which is essential for ensuring that your software is free of defects and meets the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Full-Stack Developer
Full Stack Developers are responsible for both the front-end and back-end development of a website or application. They work with a variety of technologies, including HTML, CSS, JavaScript, server-side programming languages, and databases. This course can help you learn how to write tests for both your front-end and back-end code, which is essential for ensuring that your applications are free of defects and meet the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Front-End Developer
Front End Developers are responsible for the user interface and user experience of a website or application. They work with a variety of technologies, including HTML, CSS, JavaScript, and front-end frameworks. This course can help you learn how to write tests for your front-end code, which is essential for ensuring that your applications are free of defects and meet the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Web Developer
Web Developers are responsible for designing and developing websites and web applications. They work with a variety of technologies, including HTML, CSS, JavaScript, and server-side programming languages. This course can help you learn how to write tests for your web applications, which is essential for ensuring that your applications are free of defects and meet the needs of your users. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Backend Developer
Backend Developers are responsible for the logic and data processing that happens behind the scenes of a website or application. They write server-side code that interacts with databases, handles user requests, and performs other tasks that are not visible to the user. This course can help you learn how to write tests for your backend code, which is essential for ensuring that your application is reliable and efficient. By learning how to test your code, you can help prevent bugs from reaching production and affecting your users.
Information Security Analyst
Information Security Analysts are responsible for protecting an organization's information systems from security threats. They work with a variety of tools and techniques to identify, assess, and mitigate security risks. This course may be useful for Information Security Analysts who want to learn how to test their security code. By learning how to test your code, you can help prevent security vulnerabilities from being introduced into your systems, which can lead to data breaches or other security incidents.
IT Auditor
IT Auditors are responsible for evaluating an organization's IT systems and controls to ensure that they are operating in a compliant and efficient manner. They work with a variety of tools and techniques to identify and assess risks to an organization's IT systems. This course may be useful for IT Auditors who want to learn how to test their auditing code. By learning how to test your code, you can help prevent errors from being introduced into your auditing code, which can lead to incorrect audit results and decisions.
Database Administrator
Database Administrators are responsible for managing and maintaining databases. They work with a variety of tools and techniques to ensure that databases are available, reliable, and secure. This course may be useful for Database Administrators who want to learn how to test their database code. By learning how to test your code, you can help prevent errors from being introduced into your database, which can lead to data loss or corruption.
Data Analyst
Data Analysts are responsible for collecting, cleaning, and analyzing data to identify trends and patterns. They work with a variety of tools and techniques to extract insights from data that can be used to improve business decisions. This course may be useful for Data Analysts who want to learn how to test their data analysis code. By learning how to test your code, you can help prevent errors from being introduced into your data analysis, which can lead to incorrect insights and decisions.

Reading list

We've selected 13 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 JavaScript Unit Testing - The Practical Guide.
While this book is not specific to JavaScript, it offers a comprehensive overview of unit testing principles and best practices. It covers topics such as test design, test automation, and refactoring for testability, providing valuable insights that can be applied to JavaScript testing.
A comprehensive collection of JavaScript design patterns. Provides insights into common software design problems and their solutions. Understanding these patterns can enhance the ability to write testable and maintainable code.
A comprehensive guide to JavaScript testing. Covers a wide range of testing techniques, including unit testing, integration testing, and end-to-end testing. Provides practical examples and hands-on exercises to reinforce understanding.
A guide to writing clean and maintainable code. Emphasizes the importance of code organization, readability, and testability. By applying these principles, developers can write code that is easier to test and maintain.
A focused guide to the core principles of JavaScript. Emphasizes writing clean, maintainable, and testable code. By understanding the fundamental concepts, testers can better evaluate and write effective tests.
A deep dive into functional programming techniques in JavaScript. Functional programming emphasizes immutability and pure functions, which can lead to more testable and reliable code. Understanding these concepts can benefit JavaScript testers.
Provides a practical approach to JavaScript unit testing, focusing on best practices and techniques for writing effective and maintainable tests. It covers topics such as test planning, test organization, and continuous integration, making it a valuable resource for developers looking to improve their testing processes.
A comprehensive introduction to JavaScript for experienced programmers. Provides a solid foundation in JavaScript syntax, data structures, algorithms, and object-oriented programming. This background knowledge can be beneficial for understanding the concepts and techniques covered in the course.
A highly engaging and visual introduction to Java. Provides a solid foundation in programming concepts and principles, including object-oriented programming, which can be beneficial for understanding the underlying principles of JavaScript testing.
Provides a comprehensive guide to JavaScript for software testers. It covers topics such as JavaScript basics, testing frameworks, and best practices for testing JavaScript applications, making it a valuable resource for testers looking to expand their JavaScript knowledge.
While this book focuses on test-driven development (TDD), it provides valuable insights into the principles and practices of unit testing in JavaScript. It covers topics such as test setup, assertion methods, and testing asynchronous code, making it a useful resource for developers looking to learn more about TDD and unit testing in JavaScript.
While this book focuses specifically on the Sinon testing library, it provides valuable insights into the principles and practices of mocking and spying in JavaScript unit testing. It covers topics such as creating and verifying mocks, stubbing methods, and testing asynchronous code, making it a useful resource for developers looking to learn more about this aspect of JavaScript testing.

Share

Help others find this course page by sharing it with your friends and followers:
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