Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Real-World TypeScript Unit Testing
Rating: 4.5 out of 5(16 ratings)
571 students

Real-World TypeScript Unit Testing

Create unit tests for real world typescript system with few modules using vitest or jest
Created byNathan Krasney
Last updated 10/2023
English

What you'll learn

  • Create unit tests for real world typescript client and or server applications using vitest or jest
  • Write better typescript code with less bugs
  • Ship code to production quickly and confidently
  • Represent your system using advanced diagrams : block diagram ,UML sequence diagram and UML class diagram
  • Write unit testing of pure logic code using test and expect
  • Invoke test coverage tool like istanbul
  • Write unit testing for code with side effect using spyOn , fn and mock
  • Use advanced concepts for unit testing : refactoring , debugging , filtering
  • Use isolated test and sociable test for unit test with module interaction
  • Create unit testing involving real and fake timer such as in sinonjs/fake-timers
  • Create unit testing for frontend vanilla UI using jsdom : document , querySelector
  • Create unit testing for frontend vanilla UI using dom testing library : getByText , getByRole , waitFor
  • Create unit testing for frontend react UI using react testing library : render , screen
  • Use advanced typescript for better code : union , enum , type any and unknown , polymorphism using inheritance , class diagram
  • Create unit tests using vitest and jest and compare between these tools

Course content

18 sections189 lectures12h 50m total length
  • Welcome to my course6:34

    Learn real-world TypeScript unit testing from beginner to hero, using V test and Jest, with 13 coding exercises and a real system project to practice.

  • Setup simple unit test project4:57

    learn to set up a vanilla TypeScript project in VS Code, install vitest as a dev dependency, and configure package.json to run tests with vitest.

  • Setup simple unit test project
  • Create your first unit test7:59

    Create your first unit test for a TypeScript function by placing a .test.ts file in a test directory, importing test from vitest, and validating add(1,2) equals 3.

  • Create your first unit test
  • Coding Excercise 12:15

    Practice real-world TypeScript unit testing by implementing a calculate average function using reduce and creating tests in math.tests for empty arrays (return none), a single value, and the 1,2,3 case.

  • Coding Excercise 1 solution3:56

Requirements

  • Knowledge of typescript is required

Description

You’re here because you know typescript and want to write better code with fewer bugs using unit tests.


I am here because I can help you accomplish your mission. I have B.s.c + M.s.c in mechanical engineering. I have been making software applications for over 20 years in the Hi-Tec industry and have much teaching experience. You can trust me and my teaching methods. I have learned many technologies in the past (check my LinkedIn profile), and I know exactly what is needed to learn and how.


In this course, I teach you everything you need about unit tests, and I use a real-world system, typescript, vitest, and jest.


The task of writing a unit test is not simple because there are many moving parts:

- Unit test of logic code

- Unit test of code with side effects like accessing the web

- Unit test of a module that uses another module

- Mocks

- Timers

- Unit test of UI

- Unit test of code that runs on the server

- Jsdom, testing library, react testing library

- Some tools like jest need a nontrivial setup to work with typescript and ES module

- New competitor to jest, e.g., vitest

- Coverage test


This ocean is very hard to swim without first learning it properly, and this is done in this course.


Learning in this course is not just video lessons; there are other important learning materials that most courses do not provide as a whole :

- Quiz after EVERY lesson

- Coding exercise at the end of EVERY coding section

- pdf file with all the lectures

- pdf file with a dictionary of all the material that I teach in this course



Who this course is for:

  • Students that want to write better code with less bugs using unit tests
  • Frontend developers
  • Fullstack developers
  • Backend developers
  • React developers