> For the complete documentation index, see [llms.txt](https://klassdocs.gitbook.io/klassapp-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://klassdocs.gitbook.io/klassapp-documentation/docs-site/community/tests.md).

# Tests

PHPUnit is the project standard. UI checks use Playwright under `e2e/`.

## PHPUnit

Narrow runs while you work:

```bash
php artisan test --compact tests/Feature/Path/ToYourTest.php
php artisan test --compact --filter=test_name
```

`composer.json` does not define a `test` script. Use `php artisan test`.

`phpunit.xml` registers `tests/Unit` and `tests/Feature`. `tests/Architecture/` is on disk and is not part of that default list.

There is no `npm test` script. Frontend checks are Playwright and `npm run build`.

## Full suite guard

```bash
bash scripts/test-guard.sh
```

That runs the full PHPUnit suite and compares failures with `tests/known-failures.txt`. A failure that is not on that list fails the script. A listed test that now passes also fails the script, so the list has to be updated in the same change that fixes it.

Do not export extra `phpunit.xml` variables in the shell before you run it. The script stops when those are set.

## Playwright

```bash
npm run test:e2e
```

Landing and UI scripts can also be run directly:

```bash
PREVIEW_BASE=http://127.0.0.1:8000 node e2e/your-script.cjs
```

Viewports used for landing checks are 375, 414, 768, and 1280.

## Rules for test data

* Build records with factories or a demo school seeder.
* Do not copy a real school, student, parent, or phone number into a test, a fixture, or a screenshot.
* Soft-deleted models stay in the database. Assert on `deleted_at`.
* Deletes inside a seeder stay scoped by `school_id`.

::: warning A green test is not a substitute for opening the page when the change is visible. Docs pages are not a product UI test. :::


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://klassdocs.gitbook.io/klassapp-documentation/docs-site/community/tests.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
