2025December

Testing in Umami codebase - Part 1.4

Inspired by BulletProof React, I applied its codebase architecture concepts to the Umami codebase.

This article focuses only on the testing strategies used in Umami codebase.

Prerequisites

  1. Testing in Umami codebase — Part 1.0

  2. Testing in Umami codebase — Part 1.1

  3. Testing in Umami codebase — Part 1.2

  4. Testing in Umami codebase — Part 1.3

In part 1.1, we reviewed the website.cy.ts. It has the test cases for adding, editing and deleting a website. In this part 1.2, we reviewed the login.cy.ts test cases. In this part 1.3, we reviewed the api-website.cy.ts. In this part 1.4, we review the api-user.cy.ts.

I found the following test cases defined in api-user.cy.ts

  1. Creates a user

  2. Returns all users. Admin access is required.

  3. Updates a user.

  4. Gets a user by ID.

  5. Deletes a user.

In the Part 1.3, we looked at what a fixture is. let’s choose one test case, #2 and review it.

Returns all users. Admin access is required.

You will find the following code at L30 in api-user.cy.ts:

it('Returns all users. Admin access is required.', () => {
  cy.request({
    method: 'GET',
    url: '/api/admin/users',
    headers: {
      'Content-Type': 'application/json',
      Authorization: Cypress.env('authorization'),
    },
  }).then(response => {
    expect(response.status).to.eq(200);
    expect(response.body.data[0]).to.have.property('id');
    expect(response.body.data[0]).to.have.property('username');
    expect(response.body.data[0]).to.have.property('password');
    expect(response.body.data[0]).to.have.property('role');
  });
});

This is just a cy.request and validations are made using expect 

About me:

Hey, my name is Ramu Narasinga. I study codebase architecture in large open-source projects.

Email: ramu.narasinga@gmail.com

I spent 200+ hours analyzing Supabase, shadcn/ui, LobeChat. Found the patterns that separate AI slop from production code. Stop refactoring AI slop. Start with proven patterns. Check out production-grade projects at thinkthroo.com

References:

  1. https://github.com/umami-software/umami/blob/master/cypress/e2e/api-user.cy.ts
We use cookies
We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.

Learn more