tududi/backend/tests
Chris 03f38f05dc
Setup intelligence (#84)
* Add next suggestions and remove console logs

* Add pomodoro timer

* Add pomodoro switch in settings

* Fix pomodoro setting

* Add timezones to settings

* Fix an issue with password reset

* Cleanup

* Sort tags alphabetically

* Clean up today's view

* Add an indicator for repeatedly added to today

* Refactor tags

* Add due date today item

* Move recurrence to the subtitle area

* Fix today layout

* Add a badge to Inbox items

* Move inbox badge to sidebar

* Add quotes and progress bar

* Add translations for quotes

* Fix test issues

* Add helper script for docker local

* Set up overdue tasks

* Add  linux/arm/v7 build to deploy script

* Add  linux/arm/v7 build to deploy script pt2

* Fix an issue with helmet and SSL

* Add volume db persistence

* Fix cog icon issues
2025-06-27 14:02:18 +03:00
..
helpers Setup intelligence (#84) 2025-06-27 14:02:18 +03:00
integration Setup intelligence (#84) 2025-06-27 14:02:18 +03:00
unit Move recurring elements together 2025-06-20 12:04:36 +03:00
README.md Express migration (#80) 2025-06-16 21:50:44 +03:00

Backend Test Suite

This directory contains the test suite for the tududi backend Express application.

Structure

tests/
├── unit/              # Unit tests for individual components
│   ├── models/        # Model tests
│   ├── middleware/    # Middleware tests
│   └── services/      # Service tests
├── integration/       # Integration tests for API endpoints
├── fixtures/          # Test data fixtures
└── helpers/           # Test utilities and helpers

Running Tests

All Tests

npm test

Unit Tests Only

npm run test:unit

Integration Tests Only

npm run test:integration

Watch Mode (for development)

npm run test:watch

Coverage Report

npm run test:coverage

Test Environment

Tests run in a separate test environment with:

  • In-memory SQLite database (isolated from development data)
  • Test-specific configuration from .env.test
  • Automatic database cleanup between tests

Writing Tests

Unit Tests

  • Test individual functions, models, or middleware in isolation
  • Mock external dependencies
  • Focus on business logic and edge cases

Integration Tests

  • Test complete API endpoints
  • Use authenticated requests where needed
  • Test real database interactions
  • Verify response formats and status codes

Test Utilities

  • tests/helpers/testUtils.js provides utilities for creating test data
  • tests/helpers/setup.js handles database setup and cleanup
  • Use createTestUser() for creating authenticated test users

Best Practices

  1. Isolation: Each test should be independent and not rely on other tests
  2. Cleanup: Database is automatically cleaned between tests
  3. Authentication: Use test utilities for creating authenticated requests
  4. Descriptive Names: Test names should clearly describe what is being tested
  5. Coverage: Aim for high test coverage of critical business logic

Dependencies

  • Jest: Test framework
  • Supertest: HTTP testing library for integration tests
  • cross-env: Cross-platform environment variable setting