Using Playwright Test to run Unit Tests

This page summarizes the projects mentioned and recommended in the original post on /r/javascript

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. Playwright

    Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

    For your question, it does actually not spin up a browser if you do not use page or browser in your test cases! And I wrote the blog post exactly because I think many people don't even consider to use it for unit tests, but I think it can be a viable test runner for that kind of scenarios! And just to be clear, before I released the blog post I asked the folks behind Playwright what they say about using Playwright for unit tests, and they are very supportive of that idea: https://github.com/microsoft/playwright/issues/14268

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. vitest

    Next generation testing framework powered by Vite.

    The "pros" stated in the blog post compare Playwright Test with Jest/Mocha. vitest is a very interesting, modern test framework and shares some of the pros, like TS OOTB support (as you mentioned) and it also has no globals. Still, some of the pros like "Same tool for E2E tests and unit tests" still hold only for Playwright.

  4. jest

    Delightful JavaScript Testing.

    And honestly, I had a couple of troubles with it. Like: TS is not supported out-of-the-box, so you have to configure ts-jest or something do get it even running; then, path aliases still don't work, so you have to apply some additional setup (like pathsToModuleNameMapper from ts-jest). Then I added Cypress for E2E tests and suddenly, nothing would compile because both Jest and Cypress define global typings, which conflict with each other... And at the end of the day, Jest had memory leaks such that the CI/CD system would sometimes error because of OOM issues (see e.g. https://github.com/facebook/jest/issues/11956 with 69 comments at the time of writing).

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • How To Write Unit Test Cases In React JS

    1 project | dev.to | 8 Mar 2025
  • Jest: A Delightful JavaScript Testing Framework

    1 project | dev.to | 10 Feb 2025
  • Comprehensive Guide to React Testing: From Fundamentals to Advanced Techniques

    1 project | dev.to | 29 Dec 2024
  • Angular vs. React vs. Vue

    8 projects | dev.to | 20 Dec 2024
  • React Testing: A Comprehensive Guide for Developers

    1 project | dev.to | 19 Nov 2024

Did you know that TypeScript is
the 1st most popular programming language
based on number of references?