Skip to content
Back to skills

Laravel Rust Testing

ASecurity

Testing apps built with Laravel for Rust (the laravel-rust crate, 0.1.x) with #[laravel::test]. Use when writing, reviewing or fixing tests — fakes for the queue, mail, events, notifications, the HTTP client and storage; acting_as and real logins; authorization; response, Inertia, validation and error assertions; database assertions; factories; jobs, commands, workflows and background tasks; time travel. Each rule shows a test that passes while the app is broken, fails for the wrong reason or...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsrustgoshelltestinggitapidatabasesecuritydocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 19 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add airshell/laravel-php-to-rust --skill laravel-rust-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Laravel Rust Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Laravel Rust Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/airshell-laravel-rust-testing/badge)](https://www.skillsdirectory.com/skills/airshell-laravel-rust-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel-rust-testing
description: Testing apps built with Laravel for Rust (the laravel-rust crate, 0.1.x) with #[laravel::test]. Use when writing, reviewing or fixing tests — fakes for the queue, mail, events, notifications, the HTTP client and storage; acting_as and real logins; authorization; response, Inertia, validation and error assertions; database assertions; factories; jobs, commands, workflows and background tasks; time travel. Each rule shows a test that passes while the app is broken, fails for the wrong reason or is flaky (a dropped fake, acting_as hiding a broken logout, assert_valid passing on a 500, a lenient Inertia assertion, an unawaited database assertion, an unasserted job, stacked fakes, the sync queue running delayed jobs at once) and the test to write. Every example compiles against laravel-rust 0.1.4, and the main claims were tested on that version. Complements the testing skill a new app ships; for writing app code use laravel-rust-best-practices.
license: MIT
metadata:
  author: airshell
  version: "1.0.0"
  laravelRustVersion: "0.1.x (tested 0.1.4)"
  rustVersion: "1.99+"
---

# Laravel for Rust Testing

Testing apps built with [Laravel for Rust](https://laravel.com/rust) (`laravel-rust` 0.1.x) with `#[laravel::test]`. Contains 20 rules across 6 categories. Every example compiles against `laravel-rust` 0.1.4, and each "Tested on laravel-rust 0.1.4" note records what a test on that version showed. Examples use the routes, handlers and commands of a typical app (`/login`, `/posts`, `/orders/{id}/ship`, `drafts:prune`); adapt the names to yours.

**Version 1.0.0 (December 2026).** Laravel for Rust is in beta; check APIs against the docs bundled with the version you install (`.agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh`, which needs `cargo` and `rustc` on `PATH`; otherwise `~/.cargo/registry/src/*/laravel-rust-<version>/docs`).

## When to Apply

- Writing tests for a Laravel for Rust app
- Reviewing a test suite: tests that pass while the app is broken, flaky tests, tests with real side effects
- A test fails or passes and you are not sure why

## How This Skill Fits

A new app ships `testing-laravel-rust-apps` in `.agents/skills/`, which lists the testing tools. This skill covers the ways those tools give false confidence, with the test to write instead. Two corrections to the shipped skill on 0.1.4: `acting_as` is a method on the request (`app.post(..).acting_as(&user)`), and `feature::fake(flag, value)` takes two arguments and returns nothing. For the app code itself use `laravel-rust-best-practices`; for a security audit, `laravel-rust-audit`.

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Fakes | CRITICAL | `fake-` |
| 2 | HTTP | CRITICAL | `http-` |
| 3 | Setup | HIGH | `setup-` |
| 4 | Database | HIGH | `db-` |
| 5 | Background Work | HIGH | `bg-` |
| 6 | Time | MEDIUM | `time-` |

## Quick Reference

### 1. Fakes (CRITICAL)

- `fake-bind-before-use` - Bind every fake (`let _ =` drops it); install fakes and swaps before the first request
- `fake-queue-vs-sync` - Tests run jobs inline on `sync`: delays, retries and failures behave differently; fake the queue to test dispatch
- `fake-stacked-fakes` - `event::fake` hides queued work from `queue::fake`; one layer per assertion
- `fake-http-client-strict` - Unmatched requests get an empty `200`; `prevent_stray_requests`, specific patterns first
- `fake-mail-sent-vs-queued` - `assert_sent` versus `assert_queued`; `assert_not_sent` counts both
- `fake-storage-and-flags` - `storage::fake` first; `feature::fake(flag, value)`; `fake_image` for image rules

### 2. HTTP (CRITICAL)

- `http-real-login-vs-acting-as` - `acting_as` skips the session and guards; test login and logout for real
- `http-authorization-matrix` - Guest, another user, owner; check the row after each denial
- `http-exhaustive-assertions` - Status first; `scope` and `assert_json_matches` instead of `missing`
- `http-validation-assertions` - Form redirect versus JSON `422`; never `assert_valid` alone
- `http-error-assertions` - Status and reporting, not only `assert_error::<T>()`

### 3. Setup (HIGH)

- `setup-isolation-and-ids` - Take `Application` when touching the app; never hard-code IDs
- `setup-app-factories-and-config` - `#[laravel::test(app = ..)]` for settings; one test with `APP_DEBUG=false`
- `setup-factories-and-seeding` - States before `count`; `for_` for parents

### 4. Database (HIGH)

- `db-assertions-awaited-and-specific` - `.await` every assertion; assert the changed value

### 5. Background Work (HIGH)

- `bg-assert-job-outcomes` - `app.job(..)` result must be asserted; `failed` does not run; missing models
- `bg-commands-ticks-and-schedule` - Status messages on stderr; scheduled work as functions; `app.tick`
- `bg-workflows` - Drive to a final state; stub steps by exact name
- `bg-background-tasks` - Test the function, not the race after the request

### 6. Time (MEDIUM)

- `time-travel` - `travel` and `freeze_time`, never sleep; what the clock moves and what it does not

## Reviewing a Test Suite

Search the tests for these patterns. A match is a place to read, not a finding.

| Search for | What to confirm | Rule |
|---|---|---|
| `let _ = ` with `::fake(`, or a bare `queue::fake();` statement | The fake is bound to a named variable (`storage::fake` and `feature::fake` are the exceptions) | `fake-bind-before-use` |
| `app.swap(`, `app.swap_as(` or `storage::fake(` after a request or after setup code that uses the service or a disk; a swap of a different type than the app resolves | Fakes and swaps of the same type come before anything resolves them | `fake-bind-before-use`, `fake-storage-and-flags` |
| Tests of handlers that dispatch jobs, without `queue::fake()`; `assert_pushed_where` where the count matters | The job ran inline on `sync`; delays and retries untested; `assert_pushed_times` | `fake-queue-vs-sync` |
| `event::fake()` with `queue::fake()`, `notification::fake()` with `mail::fake()`, or `mail::fake()` with `queue::fake()`, in one test | The negative assertions still mean something for the path under test | `fake-stacked-fakes` |
| `process::fake()` without `prevent_stray_processes()`; `client::fake()` without `prevent_stray_requests()`; a `"*"` pattern first; host-only patterns; `url().contains(` | Full-URL patterns, exact URL assertions, strict mode | `fake-http-client-strict` |
| `assert_sent` / `assert_not_sent` for mail the code queues | `assert_queued`; `assert_sent_times(0)` | `fake-mail-sent-vs-queued` |
| `acting_as` in login, logout, session or token-guard tests | A real login with `with_cookies_from`, or `.token(..)` | `http-real-login-vs-acting-as` |
| Tests of protected routes with only the owner | Guest and another user too, with the row checked | `http-authorization-matrix` |
| `assert_inertia()` without a status or `.component(..)`; `missing(`; `assert_json(` or `assert_dont_see` as the only proof that data is hidden | The expected status first; the component; `scope` or `assert_json_matches` without `etc()` | `http-exhaustive-assertions` |
| `assert_valid(` as the only success check | The status and the database change | `http-validation-assertions` |
| `assert_error::<` without a status, or without `assert_nothing_reported` / `assert_reported::<T>()` | The status, and the reporting the case calls for | `http-error-assertions` |
| Message assertions on 5xx responses; no test with `APP_DEBUG=false` | A production-like app factory | `setup-app-factories-and-config` |
| `"/posts/1"` and other literal IDs; `std::env::set_var` | IDs from created models; app factories | `setup-isolation-and-ids`, `setup-app-factories-and-config` |
| Factories without `for_` for the parent; shared seed data many tests rely on | Parents attached with `for_`; data built per test | `setup-factories-and-seeding` |
| `assert_database_` or `assert_model_` without `.await` (compiler warning "unused `DatabaseAssertion`") | Awaited, with the changed columns | `db-assertions-awaited-and-specific` |
| `app.job(..)` whose result is never asserted (even if other assertions follow); `assert_deleted()` | An outcome assertion on the result, and the job's effect | `bg-assert-job-outcomes` |
| `assert_output_contains` for status messages; `schedule:run` in tests | `assert_error_output_contains`; the scheduled function | `bg-commands-ticks-and-schedule` |
| `with_step("` names; `assert_step_tries(.., 0)` alone; workflow tests without a state assertion | Exact step names with `assert_step_ran`; the expected final or suspended state | `bg-workflows` |
| Assertions right after a request or command that starts background work | The function tested directly | `bg-background-tasks` |
| `sleep` used to wait for business time; `SystemTime::now`, `ZonedDateTime::now` or `Instant::now` in the code under test | `app.travel(..)`; `laravel::now()` | `time-travel` |
| Requests whose response is never asserted (`.await;` alone), or asserted only with `assert_valid`, `assert_guest` or `assert_dont_see` | A status assertion (`assert_valid` and `assert_dont_see` pass on a `404` from a route that does not exist, and so does `assert_guest` when the `404` comes from a `web` fallback route, as in new apps) | `http-validation-assertions`, `http-real-login-vs-acting-as`, `http-exhaustive-assertions` |
| Tests whose only subject is a framework API (`client::get`, `cache::put` called directly, with no app code involved) | A test of the app's handler, job or function (a general check, no dedicated rule) | — |
| `feature::fake` in tests about which users or teams get a flag | `fake_using` or the real resolver | `fake-storage-and-flags` |
| `.rs` files in subfolders of `tests/` without a `main.rs` that declares them | The tests are compiled and run at all | `setup-isolation-and-ids` |
| Tests that rely on rows from another connection or a separately started worker; no `refresh_database()` in `src/testing.rs` | Only the default connection is isolated; outside processes cannot see test rows | `setup-isolation-and-ids` |

Report each finding with the test name, how it can pass while the app is broken, the rule, and the corrected test.

## How to Use the Rules

```
rules/fake-bind-before-use.md
rules/http-real-login-vs-acting-as.md
rules/bg-assert-job-outcomes.md
```

Each rule file contains why it matters (with quotes from the docs bundled with `laravel-rust` 0.1.4), the test that passes for the wrong reason, and the test to write.

## References

- [Laravel for Rust](https://laravel.com/rust)
- [Laravel for Rust documentation](https://laravel.com/rust/docs)
- [laravel/rust skeleton](https://github.com/laravel/rust)

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

Files in this skill

  • AGENTS.md63.8 KB
  • README.md3.7 KB
  • SKILL.md10.6 KB
  • rules/_sections.md1.1 KB
  • rules/_template.md763 B
  • rules/bg-assert-job-outcomes.md2.6 KB
  • rules/bg-background-tasks.md3 KB
  • rules/bg-commands-ticks-and-schedule.md3 KB
  • rules/bg-workflows.md2.9 KB
  • rules/db-assertions-awaited-and-specific.md3 KB
  • rules/fake-bind-before-use.md3.5 KB
  • rules/fake-http-client-strict.md3.2 KB
  • rules/fake-mail-sent-vs-queued.md2.6 KB
  • rules/fake-queue-vs-sync.md3.2 KB
  • rules/fake-stacked-fakes.md3.4 KB
  • rules/fake-storage-and-flags.md3.5 KB
  • rules/http-authorization-matrix.md3.8 KB
  • rules/http-error-assertions.md2.4 KB
  • rules/http-exhaustive-assertions.md3.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.