← Back to list

Exploring a Layered Testing Approach with React, FastAPI, Pytest, Vitest, Playwright and Docker

As I continue learning more about software quality assurance and test automation, one topic that has stood out to me is how modern…

Tasfia Zaima · 2026-06-13 15:58 · 0 claps · 4.3 min read
#vitest #react-testing-library #playwrights #sqa #testing
Open on Medium ↗
Wiki topics: EDU · Education & Learning 🌐 · Web Development ☁️ · DevOps & Cloud 📚 · Books & Reading

Exploring a Layered Testing Approach with React, FastAPI, Pytest, Vitest, Playwright and Docker

As I continue learning more about software quality assurance and test automation, one topic that has stood out to me is how modern applications are tested across multiple layers.

When I first started learning test automation, most examples focused on a single tool or a specific type of test. However, real-world applications often consist of multiple components, including frontend interfaces, backend services, APIs, and deployment environments. This raises an interesting question:

How do different testing tools fit together within the same application?

This article summarizes my exploration of a layered testing approach using React, FastAPI, Pytest, Vitest, React Testing Library, Playwright and Docker.

Rather than viewing these tools as competitors, I found it more useful to think of them as solving different testing problems at different layers of the system.

Why a Layered Testing Approach Matters

Modern software systems are rarely validated through a single type of test.

Different layers of an application require different forms of validation:

  • Frontend components need to behave correctly.
  • APIs need to return expected responses.
  • Entire user workflows need to function as intended.
  • Applications should behave consistently across environments.

As a result, modern testing often combines multiple tools, with each one providing confidence at a specific level of the system.

Technology Stack

For this exploration, I looked at a stack consisting of:

Frontend

  • React
  • Vitest
  • React Testing Library

Backend

  • FastAPI
  • Pytest

End-to-End Testing

  • Playwright

Environment & Deployment

  • Docker
  • Docker Compose

Automation

  • GitHub Actions

Each tool serves a different purpose within the overall testing strategy.

Understanding the Different Testing Layers

One way to visualize the relationship between these tools is through a layered testing model.

Frontend Layer:
React Application
↓
Vitest + React Testing Library
Backend Layer :
FastAPI Services
↓
Pytest
System Layer:
Complete Application Flow
↓
Playwright
Infrastructure Layer:
Docker + CI/CD

The goal is not to test everything with a single tool.

Instead, each layer validates a different aspect of system behavior.

Frontend Testing with Vitest and React Testing Library

One of the first things I learned is that Vitest and React Testing Library serve different purposes even though they are frequently used together.

Vitest

Vitest acts as the test runner.

It is responsible for:

  • Running tests
  • Reporting results
  • Providing assertions
  • Executing tests quickly within Vite-based projects

Some advantages include:

  • Fast execution
  • Native integration with Vite
  • Familiar syntax for developers coming from Jest

React Testing Library

React Testing Library focuses on testing how users interact with components.

Instead of testing implementation details, it encourages testing behavior.

For example:

import { render, screen } from "@testing-library/react";
import { test, expect } from "vitest";
import Login from "./Login";
test("renders login button", () => {
  render(<Login />);
  expect(screen.getByText("Login")).toBeInTheDocument();
});

The objective is not to inspect internal component state but to verify what a user actually sees and interacts with.

This aligns closely with modern testing principles that emphasize user-centric validation.

Backend Testing with FastAPI and Pytest

Frontend testing alone cannot guarantee application correctness.

Backend services also need validation.

For FastAPI applications, Pytest is commonly used to verify:

  • API responses
  • Input validation
  • Error handling
  • Authentication logic
  • Edge cases

Example:

from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_search_endpoint():
    response = client.get("/search?q=testing")
    assert response.status_code == 200

Tests at this layer help ensure that services behave correctly before they are integrated into the frontend.

End-to-End Testing with Playwright

While unit and API tests validate individual pieces of the system, they cannot fully verify complete user journeys.

This is where Playwright becomes useful.

Playwright operates from the perspective of a real user interacting with a real browser.

Typical use cases include:

  • Login workflows
  • Form submissions
  • Navigation testing
  • Cross-browser validation
  • Regression testing

A simple flow might involve:

  1. Opening the application
  2. Entering credentials
  3. Submitting a form
  4. Verifying successful navigation

Rather than testing isolated components, Playwright validates how the entire system behaves together.

Understanding the Testing Pyramid

While learning these tools, I found it useful to relate them to the testing pyramid.

The idea is that:

  • Unit and component tests are numerous and fast.
  • API and integration tests are fewer.
  • End-to-end tests are the most expensive and therefore used selectively.

This helps balance coverage, execution speed, and maintenance effort.

Why Docker Matters in Testing

Testing does not happen in isolation.

Different environments can introduce inconsistencies.

Docker helps create reproducible environments by ensuring that applications run with the same dependencies and configurations across different systems.

Benefits include:

  • Consistent environments
  • Easier onboarding
  • Reliable CI/CD execution
  • Reduced environment-specific issues

This is particularly valuable when automated tests are executed across multiple machines or pipelines.

Automating Testing with CI/CD

One area I am currently exploring is how automated testing fits into CI/CD pipelines.

A typical workflow might include:

  1. Installing dependencies
  2. Running frontend tests
  3. Running backend tests
  4. Executing end-to-end tests
  5. Generating reports

Automating these checks helps catch issues earlier and improves confidence before deployment.

Who Works With These Tools?

While exploring this stack, I initially tried to associate each tool with a specific role. But in real-world software teams, these boundaries are rarely strict.

Testing responsibilities are often distributed across developers, QA engineers, and SDETs depending on how the team is structured.

Instead of focusing on who uses which tool, it becomes more meaningful to understand what level of the system is being validated.

Layered Perspective in Practice

Vitest + React Testing Library

Used for validating components and UI behavior at a fast feedback level. In many teams, this work is done by developers, but QA engineers or SDETs may also contribute depending on collaboration practices.

Pytest (Backend Testing)

Used to verify API behavior, business logic, and backend correctness. This is often handled by backend developers or SDETs, though it is not restricted to a single role.

Playwright (End-to-End Testing)

Used to validate complete user workflows in real browser environments. Commonly associated with QA and SDET workflows, but increasingly adopted across development teams as well.

What I Learned from Exploring This Stack

One of the biggest lessons for me was realizing that these tools are not alternatives to one another.

Vitest, React Testing Library, Pytest, Playwright, and Docker each address different aspects of software quality.

Instead of asking:

“Which tool should I use?”

A better question is:

“What layer of the system am I trying to validate?”

That shift in perspective makes it easier to understand where each tool fits within a broader testing strategy.

No single tool can provide complete confidence in an application.

Instead, confidence emerges from combining multiple testing layers, each designed to answer a different question about system behavior.

And understanding how these layers work together is proving to be just as important as learning the tools themselves.


메타데이터
post_id
48941a2ddd91
slug
exploring-a-layered-testing-approach-with-react-fastapi-vitest-playwright-and-docker-48941a2ddd91
url
https://medium.com/@tasfia_zaima/exploring-a-layered-testing-approach-with-react-fastapi-vitest-playwright-and-docker-48941a2ddd91
canonical_url
https://medium.com/@tasfia_zaima/exploring-a-layered-testing-approach-with-react-fastapi-vitest-playwright-and-docker-48941a2ddd91
author_url
https://medium.com/@tasfia_zaima
status
ok
fetched_at
2026-07-15 12:46:07