Pest package tests
Writes Pest tests for framework-agnostic PHP packages using Francisco Barrento's testing and naming conventions, with fbarrento/data-factory as the default for data-object test data. Use when writing, editing, or reviewing Pest tests inside a standalone Composer package (no Laravel app, no Testbench, no Eloquent), or when scaffolding a factory for a data object / DTO / value object in such a package.From its SKILL.md
npx -y skills add fbarrento/laravel-agent-kit --skill pest-package-testsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
4.2 KB, 907 tokens by cl100k_base, as published. Nobody here has run it
Pest Tests for Framework-Agnostic Packages
Use this skill for standalone Composer packages that do not boot Laravel. There is no service container, no Laravel fakes, and no Eloquent. Resolve collaborators with new, build test data with fbarrento/data-factory for data objects, and roll in-memory doubles for service dependencies.
When testing inside a full Laravel application instead, prefer the laravel-rules skill.
Quick Start
use FBarrento\DataFactory\Factory;
use Vendor\Package\Actions\CreateWaitlistSignup;
use Vendor\Package\Data\CreateWaitlistSignupData;
beforeEach(function (): void {
$this->createWaitlistSignup = new CreateWaitlistSignup();
});
test('creates a waitlist signup from data',
/**
* @throws Exception
*/
function (): void {
$data = CreateWaitlistSignupData::factory()->make();
$waitlistSignup = $this->createWaitlistSignup->handle($data);
expect($waitlistSignup->id)->toBeString()
->and($waitlistSignup->email)->toBe($data->email)
->and($waitlistSignup->createdAt)->not->toBeNull();
});
Rule Index
1. Testing -> rules/testing.md
- Use
test()for Pest tests, neverit(). - Chain expectations with
->and()instead of separateexpect()blocks. - Add an exception PHPDoc directly before any closure that may throw.
- Build setup objects with
newinbeforeEach()and assign them to$this. - Mirror
src/structure intests/Unit/. - Use
tests/Feature/for cross-cutting or integration tests. - Replace project service dependencies with in-memory doubles under
tests/Utils/. - Do not use Laravel fakes or
resolve()— the package has no Laravel container.
2. Naming -> rules/naming.md
- Test files use the
Testsuffix and mirror the source class name. - Actions are verb-first and do not use the
Actionsuffix. - Queries use the
Querysuffix; services use theServicesuffix. - Data objects use the
Datasuffix; value objects use a domain noun (noVO). - Name variables and
$thisproperties for the value they contain.
3. Architecture -> rules/architecture.md
- Keep
src/flat:Actions/,Queries/,Services/,Data/,ValueObjects/,Exceptions/. - Follow CQRS: actions mutate, queries read, services are ports to external systems.
- Use constructor injection only — no container, no singletons, no static factories.
- Data objects (
Datasuffix) carry payloads; value objects enforce domain invariants. - Throw concrete, package-namespaced exceptions from
src/Exceptions/.
4. Data Factories -> rules/data-factory.md
- Use
fbarrento/data-factoryas the default for data objects, DTOs, and value objects. - Use Eloquent factories only when the package itself depends on Eloquent.
- Place factories under
tests/Factories/and name them<Class>Factory. - Add the
HasDataFactorytrait to the class so tests callClass::factory(). - Expose readable states (
->succeeded(),->expired()) instead of inlinestate([...])overrides in tests. - Prefer
->make()for in-memory tests; reserve->create()for cases that need persistence.
Worked Example
See EXAMPLES.md for an end-to-end walkthrough: data object + factory + port + in-memory adapter + action + Pest test, all four rules applied together.
How to Apply
- Identify whether the target is a framework-agnostic package. If a Laravel application is present, switch to the
laravel-rulesskill instead. - Read the matching rule file before writing or editing tests.
- For new data-object tests, scaffold the factory under
tests/Factories/first, then write the Pest test on top of it. - Verify Pest and data-factory API syntax against the upstream docs when uncertain; this skill governs project shape, not framework APIs.
What ships with it: 5 files
17.4 KB alongside SKILL.md
rules/
- architecture.md3.2 KB
- data-factory.md1.9 KB
- naming.md2.9 KB
- testing.md4.4 KB
- EXAMPLES.md5.0 KB
Gives 0 of the 12 instructions most test skills give in 907 tokens
Counted across 964 of the 1,571 authors here whose files we hold, read 2026-08-07
- Close the browser when donein 55 of 964, across 12 files
- Wait for network idle statein 51 of 964, across 6 files
- Launch Chromium in headless modein 49 of 964, across 6 files
- Use descriptive selectors for elementsin 49 of 964, across 6 files
- Run provided scripts with help flag firstin 49 of 964, across 6 files
- Add appropriate explicit waitsin 48 of 964, across 5 files
- Use bundled scripts as black boxesin 46 of 964, across 3 files
- Do not read script source codein 46 of 964, across 3 files
- Use sync playwright for scriptsin 46 of 964, across 3 files
- Inspect dom before executing actionsin 46 of 964, across 3 files
- Run the full test suitein 37 of 964
- Write the failing test firstin 29 of 964, across 23 files
Said here and by no other author read
- Use test() for Pest tests
- Chain expectations with ->and()
- Add exception PHPDoc before throwing closures
- Mirror src/ structure in tests/Unit/
- Replace dependencies with in-memory doubles
- Resolve collaborators with new
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.