1. Manual Feature Testing

Test all critical use cases in development mode:

Feature Test Description
User Register/Login Create user, login/logout, invalid credentials
JWT Auth Ensure tokens expire and validate correctly
Cart Add/remove/update items in cart
Checkout Create order, view past orders
Admin Access Restricted to admin users only
OAuth Test Google/GitHub login
Cookies Confirm cookies are set, expire, and secure

2. Optional: Automated Testing (Jest + Supertest)

Install:

1
npm install --save-dev jest supertest

Example test (tests/auth.test.js):

1
2
3
4
5
6
7
8
9
10
11
12
const request = require('supertest');
const app = require('../app');

describe('Auth Routes', () => {
  it('should register a new user', async () => {
    const res = await request(app).post('/api/auth/register').send({
      email: 'test@example.com',
      password: 'password123'
    });
    expect(res.statusCode).toBe(200);
  });
});

In package.json:

1
2
3
"scripts": {
  "test": "jest"
}

Run:

1
npm test

3. Prepare for Production

Set Secure Cookie Options:

1
2
3
4
5
res.cookie('token', token, {
  httpOnly: true,
  secure: true, // use with HTTPS only
  sameSite: 'Lax',
});