Skip to content

mehradi-github/ref-react-typeScript-vitest

Repository files navigation

React + TypeScript + Vitest

Testing & Code Quality with Vitest and Github-actions

Introduction

Unit Testing

Testing Philosophy

When it comes to testing, a lot of the terminology is murky and things don't always mean what they originally mean. Let's settle on a common vocabulary. We'll also talk about some of the trade-offs between different kinds of tests.

Getting Warmed Up: The Basics of Unit Testing

Okay, we're not going to dwell too much on the basics of unit testing, but let's at least do a quick review of the basics to get ourselves warmed up and make sure we're on the same page. If you're a little rusty, then this section will get you up to speed. That said, I suspect that even the seasoned unit testing wunderkind, I suspect you'll still pick up a trick or two.

Great Expectations

This course doesn't seek to be the canonical curriculum on testing. Instead, all of our discussions on testing are going to be from the perspective that your primary job is to write software and if your tests are brittle or hard to maintain, you're going to stop testing.

If the section that follows was a Buzzfeed blog post, it's title would be "Top Ten Tricks to Stop Hating Your Unit Tests."

Parallelizing, Parameterizing, and Reporting

Building a CI Pipeline with Github Actions

We know that if a test doesn't fail then it technically passes. What about if you never run your tests? Join me for this and other deep philosophical questions. In this section, we'll begin building out some of our automated testing pipeline (a.k.a. continuous integration) using Github Actions.

Component Testing

Testing functions is all well and good, but what about mounting entire components? This can be a great way to get some confidence in your UI implementation without needing to figure out how to get a full browser-driven integration suite up and running. In this section, we'll get starting with Testing Library, which is a mostly framework-agnostic tool for rendering UI to a fake DOM and giving you the ability to interact with it just like a real user would.

Testing for Accessibility

Testing for Code Coverage

Storing Artifacts Using Github Actions

Mocking and Spying

Integration Testing with Playwright

Enforcing Standards

Sources

The examples used into project fork from the project Enterprise UI Development.