soyuka/contexts
Behatch contexts is a Behat extension providing ready-made contexts for browser, debug, system, JSON, table, REST, and XML testing. Configure the contexts you need in behat.yml to write common Behat tests quickly.
soyuka/contexts is a Behat extension that enhances custom helper steps in BDD. It fits well within a Laravel/PHP stack where Behat/Mink is used for acceptance testing, especially in projects needing DSL extensions for complex workflows.Behat\Testwork\ServiceContainer\Definition\ServiceDefinition).@Chris53897, @Jean-Beru, @jdeniau). This materially softens the previous "abandonment" concern, though the package remains small (low stars) and should still be tracked as a dependency with a fork contingency.soyuka/contexts. Example: replace manual Given I am logged in as admin with a context-specific step.AdminContext, UserContext) to validate step reusability, performance, and debugging ease. If JSON APIs are in scope, validate the new explicit JSON assertion messages in the PoC.$container->setDefinition('contexts', new ServiceDefinition('Soyuka\Contexts\Service'));
composer require soyuka/contexts:^3.4.1
Configure behat.yml to load custom contexts.src/FeatureContext/AdminContext.php):
namespace FeatureContext;
use Soyuka\Contexts\Context;
class AdminContext extends Context {
public function iAmAnAdmin() {
// Custom logic (e.g., Laravel Auth::loginUsingId(1))
}
}
--tags=@contexts to validate new steps; progressively replace old steps.CONTRIBUTING.md or wiki.@wip tags to isolate failing contexts during debugging.AdminContext extends BaseContext).PaymentContext, InventoryContext). Risk: overly granular contexts increase complexity.| Failure Type | Impact | Mitigation |
|---|---|---|
| Behat Configuration Error | Tests fail silently or misreport. | Use behat --dry-run pre-commit. |
| Context Step Flakiness | Non-deterministic passes/fails. | Add @retry tags or mock dependencies. |
| JSON Assertion Ambiguity | Hard-to-diagnose JSON test failures. | Resolved in v3.4.1 — explicit messages for text and count mismatches. Upgrade to benefit. |
| Package Abandonment | No updates for critical bugs. | Fork and submit PRs upstream; track release cadence. |
| UI State Drift | Steps break due to frontend changes. | Use visual regression testing (e.g., Applitools). |
| Database Inconsistency | Steps assume wrong data state. | Seed isolated test databases. |
| PHP Runtime Drift | Unknown compatibility with newer runtimes. | v3.4.1 CI-tested on 8.4/8.5; prefer ≥ v3.4.1 when upgrading PHP. |
How can I help you explore Laravel packages today?