Netpress Laravel-inspired backend framework for Node.js
Frameworkv0.1.14 Starterv0.1.12 Docsv1.0.3
Overview Installation Architecture CLI
Reference

Testing

The starter kit works well with Jest and Supertest. The goal is simple: boot the app, hit real HTTP endpoints, and assert on the response.

Quick Example

import request from "supertest";
import { createApp } from "../../../bootstrap/app.js";

let app;

beforeAll(async () => {
  app = await createApp();
});

it("registers a user", async () => {
  const response = await request(app).post("/api/v1/auth/register").send({
    name: "Test User",
    email: "test@example.com",
    password: "password123",
    password_confirmation: "password123",
  });

  expect(response.status).toBe(201);
});

Explanation

Feature tests exercise the real request lifecycle. Unit tests can call services or model wrappers directly. The existing test suite uses SQLite in memory for speed, even though the application docs focus on MySQL for runtime.

Additional Examples

Run the suite:

npm test

Test an authenticated endpoint:

const login = await request(app).post("/api/v1/auth/login").send({
  email: "test@example.com",
  password: "password123",
});

const me = await request(app)
  .get("/api/v1/auth/me")
  .set("Authorization", `Bearer ${login.body.data.accessToken}`);

expect(me.status).toBe(200);

Advanced Usage

As your app grows, keep feature tests around the public HTTP behavior and unit tests around reusable service logic. That balance gives fast feedback without losing confidence.

Notes / Tips

  • Reset or isolate database state between tests.
  • Use feature tests for routes, middleware, and controllers together.
  • Use unit tests for service and model wrapper behavior.