Rocket.Chat Developer Guide

 

Start

# Start development server
TEST_MODE=true yarn dsv

That’s it. The dev server runs on http://localhost:3000 with test mode on.

Debugging & Testing

Running API Tests

# Test all Chat endpoints
cd apps/meteor
yarn testapi -f '[Chat]'

# Test specific endpoint
yarn testapi -f 'should create a direct message'

# Run all API tests
yarn testapi

Node.js Debugging

cd apps/meteor
yarn debug-brk

Then open Chrome DevTools at chrome://inspect. The --brk flag pauses execution at the first line, giving you time to set breakpoints.

End-to-End Tests

# Run all E2E tests
yarn test:e2e

# Run specific test file
yarn test:e2e --grep "direct-message"

# Run federation tests
yarn test:e2e:federation

Git Workflow

Safe Reset Patterns

Here’s how I recover when I mess up my local branches:

# Undo last commit, keep changes staged
git reset --soft HEAD~1

# Undo last commit, keep changes unstaged
git reset HEAD~1

# Reset to match develop branch
git reset --soft develop

Cleaning Up

# Remove untracked files and directories
git clean -xdf

# Preview what will be deleted (safe)
git clean -xdfn

The -x flag removes ignored files (like node_modules). Use it when your build is broken and you want a fresh start.

Force Push

# Safer than --force
git push --force-with-lease

Formatting & Linting

Auto-Fix Everything

# Fix ESLint issues
yarn eslint:fix

# Fix Stylelint issues
yarn stylelint:fix

# Run all linters (no auto-fix)
yarn lint

Linting Specific Files

cd apps/meteor
yarn eslint --fix app/api/server/v1/subscriptions.ts

Environment Variables

Key variables I set frequently:

# Enable test mode
TEST_MODE=true

# Enable debug logging
export LOG_LEVEL=debug

Testing

Unit Tests

# Run all unit tests with coverage
yarn testunit

# Run tests in watch mode
yarn testunit-watch

# Run specific test file
cd apps/meteor
yarn jest server/methods/createDirectMessage.spec.ts

Test Organization

  1. Unit tests: *.spec.ts files next to source code
  2. API tests: tests/end-to-end/api/ directory
  3. E2E tests: tests/end-to-end/ directory

Common Issues

Build Failures

# Clear Turbo cache
rm -rf .turbo

# Clear all node_modules
yarn clean
yarn install

MongoDB Connection Issues

# Check if MongoDB is running
docker ps | grep mongo

# Restart MongoDB
docker-compose -f docker-compose-local.yml restart mongo

Port Already in Use

# Find process using port 3000
lsof -i :3000

# Kill the process
kill -9 <PID>

Resources


This guide reflects my workflow. Your mileage may vary.

Last updated

This work is licensed under a Attribution-NonCommercial 4.0 International license. Attribution-NonCommercial 4.0 International

Enjoy this article?

If you found this helpful, consider buying me a coffee! It helps me create more content like this.

Buy Me A Coffee