Skip to content

Docs Contributing to the app

Testing

Run the PHP and JavaScript tests of Feedback Pilgrim, and learn which tests guard which rules.

Run the tests

Run all the PHP tests:

Terminal

php artisan test

Run one test class or method:

Terminal

php artisan test --filter=WebhookTest

Run the JavaScript tests:

Terminal

npm run test:js

Format the PHP code:

Terminal

vendor/bin/pint

The test environment

The tests use PHPUnit and the values in phpunit.xml. You do not need MySQL or Redis.

Variable Value in phpunit.xml
DB_CONNECTION sqlite
DB_DATABASE :memory:
CACHE_DRIVER array
QUEUE_CONNECTION sync
SESSION_DRIVER array
MAIL_MAILER array
APP_DOMAIN localhost
APP_URL http://localhost
REGISTRATION_ENABLED false
BCRYPT_ROUNDS 4

Where the tests are

Folder Content
tests/Feature Request and response tests, for example the public API, the widget, the MCP server, the tenancy rules and the commands.
tests/Unit Tests for classes without HTTP, for example the actions, the rules and the models.
tests/js Node tests for the widget and the Blade templates.

Tests that guard a rule

Test Rule
tests/Feature/Mcp/ContractTest.php The validation rules, the MCP tool schemas and public/docs/openapi.json agree.
tests/Feature/RouteNamesTest.php Each route name is unique, so that php artisan optimize can cache the routes.
tests/Feature/DocumentationTest.php The guides and the API reference at /documentation work.
tests/js/pilgrim-origin.test.mjs The widget builds the init URL from the host of its own script tag.
tests/js/server-template.test.mjs The Blade views use no Vue text interpolation.

Write a test

  • Every change needs a test. Write the test first when you add behavior.
  • Put request and response tests in tests/Feature. Put tests for classes without HTTP in tests/Unit.
  • Use the model factories and the RefreshDatabase trait.
  • Name a test after the behavior that it checks, for example test_onboarding_creates_the_admin_contact_for_the_new_client.

Before a pull request

Make sure that these commands pass:

Terminal

php artisan test
vendor/bin/pint --test
npm run build

The CI

.github/workflows/ci.yml runs on each push to main and on each pull request. It has four jobs:

Job What it runs
Code style (Pint) vendor/bin/pint --test on PHP 8.3
PHP tests cp .env.example .env, php artisan key:generate, then php artisan test
JS build npm ci, npm run build and npm run test:js on Node.js 24. Then it makes sure that public/pilgrim.js and public/build/manifest.json exist.
API docs composer api-docs, then git diff --exit-code docs/api public/docs/openapi.json. The job fails when the generated API files are not current.

If you change docs/api/openapi.yaml, run composer api-docs and commit the generated files.

Edit this page on GitHub