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.
Install the plugin via Composer:
composer require --dev faissaloux/pest-plugin-inside
No additional configuration is required—Pest auto-discovers it. Begin by replacing traditional expect() calls with inside() when testing object boundaries or domain contexts. For example:
use function Pest faissaloux\Inside\inside;
describe('User::fullName()', function () {
$user = new User('John', 'Doe');
it('returns the full name', function () {
inside($user)->expect(fn () => $this->fullName())->toBe('John Doe');
});
});
Start here if your tests have repeated setup for object state or you want to signal where an assertion is semantically anchored.
inside($invoice)->expect(fn () => $this->total())->toBe(100.00);
$user = UserFactory::new()->create();
inside($user)->group('authentication', fn () => [
expect($user->isActive())->toBeTrue(),
expect($user->email())->toContain('@example.com'),
]);
inside() calls for layered boundaries (e.g., inside($repository)->inside($entity)) where each scope carries semantic meaning.with(), in(), and see()—use inside() only for object-bound assertions to avoid overuse.inside() on objects that mutate state mid-test. Ensure the object is fully constructed before passing it in.inside() executes in the object’s scope ($this → object instance). Conflicts arise if the object has __call() or dynamic methods—use ::class or get_class($this) to verify context. pest('inside')->shouldCallOriginal() to fallback to raw expectations if unexpected behavior occurs.inside() for trivial scalar comparisons (e.g., expect($foo)->toBe(1)). Reserve it for domain complexity.InsideContext—subclass it to add custom domain helpers (e.g., inside($order)->assertProcessed()).How can I help you explore Laravel packages today?