Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Pest Plugin Inside

Pest Plugin Inside Laravel Package

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.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Pest Plugin Inside
How do I install Pest Plugin Inside for Laravel projects?
Run `composer require --dev faissaloux/pest-plugin-inside` in your Laravel project. The plugin works with Pest PHP (v2.14+) and requires PHP 8.1+. No Laravel-specific dependencies are needed, so it integrates seamlessly with existing Pest test suites.
Can I use this plugin to validate Laravel config files or migration stubs?
Yes, the plugin supports PHP arrays, `.txt`, and `.stub` files—perfect for validating Laravel config files, migration stubs, or Blade templates. For example, use `expect('config/custom.php')->toReturnLowercase()` to enforce lowercase keys in your config.
Will this plugin work with Pest v5+ or only older versions?
The plugin supports Pest v2.14+ to v5+. Check the [requirements table](https://github.com/faissaloux/pest-plugin-inside#requirements) for version-specific constraints. Pin your Pest version in `composer.json` to avoid compatibility issues, e.g., `^5.0` for Pest 5+.
How do I test file content in a Laravel service provider or model?
Bootstrap your Laravel app in Pest tests using `Pest::actingAs()` or `Pest::withoutMiddleware()`, then use the plugin’s assertions. For example, test a config file generated by a service provider with `expect('config/generated.php')->toReturnUnique()`.
What happens if a test fails due to file content validation?
Failed assertions will halt the test suite and show a descriptive error message, just like standard Pest assertions. Use this in CI/CD pipelines to enforce file standards—align failure handling with your team’s testing policies (e.g., block deployments or require manual review).
Does this plugin replace PHP-CS-Fixer or Laravel’s PHPUnit?
No, it complements them. PHP-CS-Fixer handles code *style* (e.g., PSR-12), while this plugin validates *semantic content* (e.g., lowercase keys, unique values). Use both for comprehensive testing: PHP-CS-Fixer for syntax and this plugin for business logic in files.
How do I exclude certain files or directories from validation?
The plugin doesn’t natively support exclusions, but you can work around this by organizing tests. For example, create a separate test file for excluded directories (e.g., `tests/Validation/ConfigTest.php`) and skip them in other test files. Alternatively, use Pest’s `skip()` method for specific assertions.
Are there performance concerns with scanning large directories?
Recursive directory scanning (e.g., `expect('storage/')->toReturnLowercase()`) can slow down tests if applied to large file trees. Benchmark with your actual file structure and limit assertions to critical paths (e.g., `config/`, `database/migrations/`). Avoid scanning `vendor/` or generated directories.
How do I handle multilingual content (e.g., Arabic text) in assertions?
The plugin’s assertions like `toReturnLowercase()` or `toBeOrdered()` rely on PHP’s native string functions, which may not handle all Unicode cases perfectly. Test edge cases (e.g., Arabic lowercase) in your suite and document limitations. For strict multilingual validation, combine with custom assertions or libraries like `symfony/string`.
What’s the maintenance process if file formats change (e.g., new config keys added)?
Update the assertions in your test files to reflect new requirements. For example, if a config file gains a new key, modify `expect('config/app.php')->toReturnLowercase()` to include the new key. Document ownership in your `CONTRIBUTING.md` or team wiki to clarify who updates these tests.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata