Introduction
JCC Express MVC includes a Laravel-style testing layer for HTTP and database testing.
It is built around a base TestCase class plus helper classes that let you:
- boot a real app instance for each test
- make HTTP requests (
get,post,put,patch,delete) - assert responses with fluent assertions
- assert database state after actions
Core pieces
Main testing classes in the framework:
jcc-express-mvc/lib/Testing/TestCase.tsjcc-express-mvc/lib/Testing/Concerns/MakesHttpRequests.tsjcc-express-mvc/lib/Testing/TestResponse.tsjcc-express-mvc/lib/Testing/Concerns/InteractsWithDatabase.ts
Create your project test case
Create tests/TestCase.ts and extend the framework base class:
TypeScript
setUp() and tearDown() are provided by the base TestCase and should be called in your test runner hooks.
Your first feature test
TypeScript
HTTP helpers and response assertions
From TestCase, you can call:
get(uri, headers?)post(uri, data?, headers?)put(uri, data?, headers?)patch(uri, data?, headers?)delete(uri, data?, headers?)
Common TestResponse assertions:
assertStatus(...),assertOk(),assertCreated()assertForbidden(),assertNotFound(),assertUnprocessable()assertJson(...),assertJsonFragment(...),assertSee(...)json(),text()
Database assertions
Use built-in DB assertions from TestCase:
TypeScript
Generating tests with ArtisanNode
Generate a feature test scaffold:
Bash
This creates a test file in tests/Feature with starter setup/teardown and request assertion flow.
Running tests
If you use the default project scripts:
Bash
You can also run Bun test directly:
Bash
Use whichever test runner matches your project workflow.
