Skip to content

Testing

Test your TruSpace changes.

Running Tests

Backend Tests

cd backend
npm test
npm run test:watch    # Watch mode
npm run test:coverage # With coverage

Frontend Tests

cd frontend
npm test
npm run test:e2e  # E2E tests

Writing Tests

Unit Tests

Use Jest for unit testing:

describe('MyService', () => {
  it('should do something', () => {
    expect(result).toBe(expected);
  });
});

Integration Tests

Test API endpoints with supertest:

import request from 'supertest';

describe('GET /api/workspaces', () => {
  it('returns workspaces', async () => {
    const res = await request(app)
      .get('/api/workspaces')
      .set('Authorization', `Bearer ${token}`);
    expect(res.status).toBe(200);
  });
});

E2E Tests

Playwright tests in e2e-tests/:

cd e2e-tests
npm test