Performance: Testing GET endpoints
LOW IMPACT
Testing GET endpoints affects development speed and reliability but can indirectly impact user experience by ensuring fast and correct responses.
import request from 'supertest'; import app from './app'; describe('GET /items', () => { it('responds with JSON', async () => { const res = await request(app).get('/items'); expect(res.statusCode).toBe(200); expect(res.body).toBeDefined(); }); });
const request = require('supertest'); const app = require('./app'); describe('GET /items', () => { it('responds with JSON', (done) => { request(app) .get('/items') .end((err, res) => { if (err) return done(err); expect(res.statusCode).toBe(200); expect(res.body).toBeDefined(); done(); }); }); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Callback style test with .end() | 0 | 0 | 0 | [X] Bad |
| Async/await style test | 0 | 0 | 0 | [OK] Good |