IntegrationTests - IEEE-Team-3/map GitHub Wiki
Test the interaction between modules and services (e.g., APIs, DB, frontend-backend flow).
// server/tests/routes/tasks.test.ts
import request from 'supertest';
import app from '../../app';
describe('POST /api/tasks', () => {
it('should create a task and return 201', async () => {
const res = await request(app)
.post('/api/tasks')
.send({ title: 'New Task', points: 10 });
expect(res.statusCode).toEqual(201);
expect(res.body.task.title).toBe('New Task');
});
});
- Use Cypress for E2E or Playwright
- Test frontend + backend communication
// cypress/e2e/login.cy.js
describe('Login Flow', () => {
it('logs the user in successfully', () => {
cy.visit('/login');
cy.get('input[name="email"]').type('[email protected]');
cy.get('input[name="password"]').type('123456');
cy.get('button[type="submit"]').click();
cy.url().should('include', '/dashboard');
});
});
- Use seed/mock data for consistency
- Reset database before tests
- Test authorization and role-based flows