faissaloux/pest-plugin-inside
Pest plugin to run tests from inside your app’s context. Provides helpers to bootstrap Laravel or other frameworks for faster, cleaner integration-style tests without leaving Pest. Simple setup, lightweight, and aimed at improving developer ergonomics.
expect() syntax, making it intuitive for teams already familiar with Pest.faissaloux/pest-plugin-inside) and zero configuration. Assertions are chainable (e.g., expect('file.php')->toReturnLowercase()->toReturnUnique()), reducing test verbosity..txt, and .stub files, covering common Laravel use cases (e.g., migration stubs, config templates).composer.json or using ^ constraints cautiously.toBeOrdered() or toReturnUnique() may produce unexpected failures if edge cases (e.g., locale-specific sorting, mixed data types) aren’t anticipated. Requires test author awareness of plugin limitations.expect('directory')->toReturnLowercase()) could slow down test suites if applied to large file trees. Benchmark with real-world file structures pre-adoption.vendor/ or generated files)..php files must use lowercase keys) or context-specific (e.g., only database/migrations/ files)?CONTRIBUTING.md.config/, database/migrations/).phpunit: Pest is preferred for its fluent syntax and Laravel integration.config/, stubs/).composer require --dev faissaloux/pest-plugin-inside
FileValidationTest.php.// Before: Manual check in CI script
if (!file_exists('config/custom.php') || strpos(file_get_contents('config/custom.php'), 'lowercase_key') === false) {
throw new Exception('Config file invalid!');
}
// After: Pest assertion
expect('config/custom.php')->toReturnLowercase()->toReturnUnique();
depth parameter to control directory scanning scope.composer.json to avoid surprises:
"require-dev": {
"pestphp/pest": "^5.0",
"faissaloux/pest-plugin-inside": "^1.11"
}
- name: Run Pest with file assertions
run: vendor/bin/pest
README.md or TESTING.md.composer why-not to check for outdated packages.toReturnLowercase() fails due to new config keys). Example:
// Update test if new keys are added
expect('config/app.php')->toReturnLowercase()->forbidEmpty();
dd(file_get_contents('file.php')) to inspect raw content.\r\n) may affect text file parsing; normalize with str_replace() if needed.--filter or comment them out during transitions.database/migrations/) to measure impact. Use depth: 1 to limit scope if needed.docs/ folder.depth: 0 for shallow scans.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Assertion fails in CI | Build blocked | Configure as warn-only or require manual review. |
| Unsupported Pest/PHP version | Tests break | Pin versions in composer.json. |
False positive (e.g., toBeOrdered) |
Test flakiness | Add comments or disable assertion temporarily. |
| Permission denied on CI | Tests skip files | Ensure CI |
How can I help you explore Laravel packages today?