Skip to content
Guide

Test an App

Check the changed App behavior and finish the onboarding evidence.

Test an App

Run the generated Note authorization declaration test from the Core root after Create a Resource:

Code example
Shell
task test -- packages/workshop/tests/Feature/NoteAuthorizationTest.php --compact
task artisan -- nexia-apps:doctor-package-app workshop

Verify

The named test actually executes and succeeds; the doctor has no FAIL. Add the behavioral checks below for the changed risk rather than treating those two results as full coverage.

The test asserts the Module's ownership and permission profile. The doctor checks package wiring. Neither proves that an HTTP write is authorized or persisted correctly.

Choose the smallest behavioral test

Keep tests in your App's tests/ directory. The scaffold declares extra.nexia.test_paths: ["tests"] and creates this package-local Pest binding:

Code example
PHP
use Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
ChangeTest through the real boundary
New category fieldAuthorized create/update round trip, null clearing, over-80-character rejection
Permission or ownershipAllowed actor, denied actor, other organization, other tenant; list and record agree
MigrationExisting rows survive; DB constraint rejects invalid writes
Event handlerRepeated delivery produces one effect; missing tenant and revoked authority fail safely
InitializationRepeated repair produces the same row set

Use a tenant fixture with Workshop operational before testing its endpoint. Otherwise app.installed:workshop can refuse the request before the Policy. Resolve SDK test-host contracts for host-owned state: Nexia\Testing\Contracts\ContributionTestHost, HostTestStore, or ApprovalTestHost as appropriate. Do not import host Eloquent models into App tests. Test-specific actor and installation fixture APIs are documented in SDK contracts.

A tenant-context helper does not automatically set the HTTP host; the request must target the tenant domain. Assert the intended endpoint status, including deliberate not-found responses that conceal out-of-scope records.

Run in the development container

Code example
Shell
task test -- packages/workshop/tests --sequential --compact

The wrapper resolves the database inside Docker. Host-shell Pest cannot resolve the postgres service; changing DB_HOST to work around that can select the wrong database. Use Fix test failures for tenant lifecycle, parallel bindings and template database issues. Missing test key on an older checkout can be repaired with task artisan -- key:generate --env=testing --ansi.

Run frontend tests only when they cover changed behavior, using the package path through the host's frontend tooling. Full task check belongs to an explicitly requested full gate or a develop → main promotion, not every edit.

For an App that has frontend test files, run only that App’s path from the Core root:

Code example
Shell
task frontend:test -- packages/workshop/resources/js

The Note generator does not create frontend tests; an empty selection is not a passing test result.

Finish onboarding

Reuse evidence already collected for the same source state:

ResultEvidence
Local host worksQuickstart doctor and tenant sign-in
Correct source is loadedComposer-installed path matches your App root
Lifecycle worksActivation, targeted migration and tenant installation
Screen worksCreate, list, Inspector, detail and edit a Note

Inspect git status --short in Core and the App separately. Activation can add a workspace importer to Core's pnpm-lock.yaml; the ignored App directory does not guarantee an unchanged Core tree. Review those changes without discarding unrelated work. Do not rerun successful onboarding gates merely to collect a final success phrase.

For a release, continue with Release an App. Record the exact candidate commits and executed checks; an unexecuted test plan is not verification.

Source of truth: docs/developers/content/en/building-apps/test-an-app.md