Implementing End-to-End Tests for Production Environment with Vercel and Neon
TL;DR: I added end-to-end tests for the production environment of Lavanderia CRM, integrating Vercel and Neon databases using GitHub Actions v5. This change enhances the CI/CD pipeline by ensuring the application's API works as expected in production.
The Problem
The Lavanderia CRM application, built with a full-stack architecture, lacked comprehensive end-to-end (E2E) tests for its production environment. The existing tests were limited to local development and didn't validate the application's behavior in the production environment, which is hosted on Vercel and uses a Neon database. The goal was to create a robust E2E testing strategy that could run automatically against the production API.
What I Tried First
Initially, I attempted to use the existing local E2E tests and adapt them for production. However, this approach required significant modifications to accommodate the differences between local and production environments, such as database connections and API endpoints. I also explored using a staging environment for testing, but it wasn't feasible due to the complexity of managing multiple environments.
The Implementation
To implement E2E tests for the production environment, I made the following changes:
1. Update .github/workflows/ci.yml
First, I updated the ci.yml file to use Actions v5:
steps:
- uses: actions/checkout@v5
- name: Setup Node 20
uses: actions/setup-node@v5
with:
node-version: '20'
This change ensures that the workflow uses the latest version of Actions.
2. Add .github/workflows/e2e-production.yml
Next, I created a new workflow file, e2e-production.yml, to handle the E2E tests for production:
name: End-to-End Tests — Producción Lavandería CRM
on:
push:
branches: [main]
workflow_dispatch: {}
schedule:
- cron: 0 6 * * * # 06:15 UTC diario
jobs:
e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node 20
uses: actions/setup-node@v5
with:
node-version: '20'
- run: npm install
- run: npm run test:e2e-production
This workflow triggers daily at 06:15 UTC and runs the E2E tests against the production environment.
3. Update apps/api/package.json
I added a new script to run the E2E tests against production:
"scripts": {
"test": "vitest run",
"test:local": "DATABASE_URL=postgresql://postgres:postgres@localhost:5436/lavanderia_crm JWT_SECRET=test-secret-32-chars-minimum-ok!! vitest run",
"test:e2e-production": "DATABASE_URL=https://lavanderia-crm.neon.tech/api vitest run --config=vitest.config.e2e-production.ts"
}
This script uses the vitest runner with a specific configuration file for E2E tests.
4. Add apps/api/src/__tests__/e2e-production.spec.ts
Finally, I created a new test file, e2e-production.spec.ts, which contains the E2E tests for the production environment:
import axios from 'axios';
describe('E2E Tests — Producción Lavandería CRM', () => {
it('should return a successful response', async () => {
const response = await axios.get('https://lavanderia-crm.vercel.app/api/healthcheck');
expect(response.status).toBe(200);
});
// Additional tests for API endpoints
});
This test file uses axios to send HTTP requests to the production API and verifies the responses.
Key Takeaway
The key takeaway from this implementation is the importance of having a comprehensive E2E testing strategy for production environments. By integrating E2E tests into the CI/CD pipeline, we can ensure that the application works as expected in production, reducing the risk of errors and downtime.
What's Next
Next, I plan to monitor the E2E tests' performance and adjust the test suite as needed to ensure optimal coverage. Additionally, I will explore integrating more advanced testing tools, such as Cypress or Playwright, to enhance the testing strategy.
vibecoding #buildinpublic #e2e-testing #vercel #neon #github-actions
Part of my Build in Public series — sharing the real process of building Building Lavandería CRM from Playa del Carmen, México.
Repo: zaerohell/lavanderia-crm · 2026-07-02
#playadev #buildinpublic
Top comments (0)