akeneo/phpspec-skip-example-extension
A phpspec extension from Akeneo that lets you skip selected examples in your specs, so you can temporarily disable tests without deleting or commenting them out. Handy for work-in-progress specs and known failures during refactoring.
Install the extension as a dev dependency, matching the major version to your PhpSpec version. As of v5.0.0 the package supports PhpSpec 6.0 and 7.0; if you are still on PhpSpec 5.x you need the previous major:
# PhpSpec 6.x / 7.x
composer require --dev akeneo/phpspec-skip-example-extension:^5.0
# PhpSpec 5.x and older
composer require --dev akeneo/phpspec-skip-example-extension:^4.0
Register it in phpspec.yml. PhpSpec extensions live under the extensions key, keyed by the extension class FQCN. Check the README (or src/) of the installed version for the exact class name before copy-pasting — a major bump can move or rename classes, and a typo here fails silently (the extension simply never loads):
extensions:
Akeneo\SkipExampleExtension\Extension\SkipExampleExtension: ~
Annotate an example you want to skip. Annotations are read from the example's docblock:
class CalculatorSpec extends ObjectBehavior
{
function it_adds_two_numbers()
{
$this->add(1, 2)->shouldReturn(3);
}
/**
* @skip waiting for the new Money value object
*/
function it_handles_currency_conversion()
{
// not implemented yet
}
}
Run vendor/bin/phpspec run. The annotated example should be reported as skipped rather than executed.
Where to look first: the README of the installed tag for the exact extension FQCN and supported annotations, then the src/ listener that parses annotations and decorates the example runner, and the package's own spec/ directory — it is the most reliable reference for edge cases the README does not cover, and it is also what proves the 6.0/7.0 compatibility claim.
First use case: quarantining a single known-broken or not-yet-implemented example so the suite stays green while the spec (the intent, not the body) stays in the codebase and visible in the report.
@skip on a single it_* method to remove it from execution without deleting the specification. This is the primary supported pattern./**
* @skip JIRA-4821 flaky when the clock crosses midnight
*/
spec/ before relying on it.@skip with a reference, fix the production code in a follow-up commit, remove the annotation in the same PR that fixes it. Reviewers should treat the annotation as a TODO.--format=progress or a pretty formatter) so skips are visible in CI logs rather than invisible. Optionally grep the output and fail the build above a skip threshold to stop quarantine debt from growing unnoticed.phpspec.yml suites with different src_path/spec_path) for environment gating; reserve @skip for examples that are genuinely broken everywhere.let/letgo. Keep the skipped example's setup meaningful — the spec body should still read as the intended contract even though it never runs, because the next developer will un-skip it and expect the setup to work.@skip documents the target interface, then the annotation comes off in the implementation PR. It is a lightweight alternative to keeping a spec-ideas.md file.@skipOnWindows or @skipUnlessCi. Fork the listener and register your subclass in phpspec.yml rather than patching vendor code. Since v5.0.0 is the PhpSpec 6/7 branch, target that if your suite has moved forward.// or #), the annotation must be at line start, and the parser is usually a simple regex — @skip inside prose may or may not match depending on the implementation. Do not use @skip() or @Skip.let()/letgo()/constructor may still execute. Do not use @skip as a way to avoid expensive or side-effecting setup; assert on the output rather than assuming nothing ran.--stop-on-failure and exit codes are unaffected. Do not mistake a growing skip count for a healthy suite.phpspec.yml can change behaviour. Put this extension early if skips are not being honoured.vendor/bin/phpspec run <spec>:<example> --format=pretty -v and check that the annotation lands on the method (not inherited from an interface or trait — PhpSpec does not reliably read annotations from traits).@skip in a spec you also run in another suite expecting it to execute; the annotation is unconditional and there is no built-in environment predicate. If you need conditionals, write a small custom listener.PendingException/skipping exception covers most needs without a third-party dependency. Keep this package for legacy suites already standardised on the annotation, and prefer Pest/PHPUnit for new projects — v5.0.0 keeps existing suites viable, it is not a reason to start new ones on PhpSpec 7.How can I help you explore Laravel packages today?