Skip to content

fix(ci): separate unit/E2E tests and fix commitlint ESM config#11

Merged
diego64 merged 1 commit into
mainfrom
fix/ci-separar-testes-unitarios-e2e
Jun 4, 2026
Merged

fix(ci): separate unit/E2E tests and fix commitlint ESM config#11
diego64 merged 1 commit into
mainfrom
fix/ci-separar-testes-unitarios-e2e

Conversation

@diego64

@diego64 diego64 commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Split the testes job into two sequential jobs: testes-unitarios (no external services) and testes-e2e (MongoDB + Redis)
  • Activate the E2E tests job with correctly-credentialed service containers
  • Activate the coverage job (unit tests only)
  • Convert commitlint.config.jscommitlint.config.cjs to fix ESM incompatibility in CI

Root Causes

1 — E2E tests running without database services

The testes job ran pnpm test, which executes vitest run against src/testes/**/*.test.ts — including the four E2E suites. Those suites call conectarBdTeste() and obterRedis() in beforeAll, but the runner had no MongoDB or Redis available. The beforeAll hook timed out at 10 000 ms, then bd was undefined, causing the cascade:

Error: Hook timed out in 10000ms.
TypeError: Cannot read properties of undefined (reading 'collection')

2 — commitlint ESM incompatibility

commitlint.config.js used export default (ESM) because package.json declares "type": "module". The wagoid/commitlint-github-action@v6 Docker container cannot reliably load ESM config files, producing a generic Error: You have commit messages with errors regardless of commit content.

Changes

ci.yml

Before After
Single testes job: pnpm test (all tests, no services) testes-unitarios: vitest run src/testes/unitarios (no services)
E2E job commented out testes-e2e: vitest run src/testes/e2e with MongoDB 8.0 + Redis 8 services
Coverage job commented out cobertura: vitest run --coverage src/testes/unitarios

Service credentials match auxiliar-bd.ts defaults:

  • MongoDB: administrador:1qaz2sx12 (auth source: admin)
  • Redis: no-auth (REDIS_URL=redis://localhost:6379)

Pipeline order:

qualidade → testes-unitarios → testes-e2e
                             → cobertura

commitlint.config.jscommitlint.config.cjs

Renamed and converted to CommonJS (module.exports = {...}). Identical rules, universal compatibility. Updated commitlint.yml to reference the .cjs file.

Test plan

# Unit tests (no services needed)
pnpm exec vitest run src/testes/unitarios
# → 296 tests, 28 files, all green

# Full lint + typecheck
pnpm lint && pnpm typecheck
# → no errors

E2E tests are validated by the new testes-e2e CI job running against the service containers.

🤖 Generated with Claude Code

@gitguardian

gitguardian Bot commented Jun 4, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
33202264 Triggered Username Password 17895aa .github/workflows/ci.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@diego64 diego64 merged commit 02cc749 into main Jun 4, 2026
2 of 3 checks passed
@diego64 diego64 deleted the fix/ci-separar-testes-unitarios-e2e branch June 4, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant