Weave 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
Behat Http Mock Context

Behat Http Mock Context Laravel Package

macpaw/behat-http-mock-context

A Behat context from MacPaw for mocking HTTP interactions in acceptance tests. Stub external HTTP calls and assert requests/responses so scenarios run reliably without live services or network dependencies.

View on GitHub
Deep Wiki
Context7

Behat Context Mock HTTP Response in Testing

Frequently asked questions about Behat Http Mock Context
Is macpaw/behat-http-mock-context a Laravel package?
No, it is a Behat context extension for mocking HTTP interactions in acceptance tests. Laravel's native testing stack is PHPUnit or Pest with Http::fake(), which already covers HTTP faking at the framework layer. Adopting this package means adding Behat as a second test harness, not installing a drop-in Laravel package.
How do I install macpaw/behat-http-mock-context in a Laravel project?
Install it with Composer and register the context in your Behat suite. Laravel has no first-class Behat integration, so you must manually bootstrap the application kernel, resolve the container, and manage per-scenario teardown. Verify Composer constraints for PHP, Guzzle, and Behat before installing.
Does macpaw/behat-http-mock-context work with Laravel's Http facade?
It depends on where interception happens. If the package operates on the Guzzle handler stack, it may compose with Illuminate\Support\Facades\Http because that facade wraps Guzzle. If it requires its own client or mocks at a higher layer, Http facade calls can bypass it and silently hit the network. You must spike this against a real service class before adopting it.
How does macpaw/behat-http-mock-context intercept HTTP requests?
The package is a Behat context that plugs into Behat's context and step-definition lifecycle to intercept outbound HTTP and return canned responses. The critical unknown is whether interception happens at the Guzzle handler level or higher. That determines whether Laravel code using the Http facade is actually covered.
Can I use macpaw/behat-http-mock-context with Pest or PHPUnit?
Not as a replacement. The package is built for Behat, so Pest and PHPUnit suites would need to run Behat separately. Laravel teams should keep Pest or PHPUnit with Http::fake() for unit and feature tests and treat Behat as an isolated acceptance-test job if they adopt it at all. Do not try to replace Pest with this package.
What Behat and PHP versions does macpaw/behat-http-mock-context support?
The assessment flags Behat 3.x versus current Behat as an open question and lists PHP 8.1, 8.2, and 8.3 plus Guzzle 7 as items to verify. There is one release in 2024 and no evidence of production use outside MacPaw. Check Composer constraints against your target Laravel version, PHP minor, and Guzzle major before committing.
Does macpaw/behat-http-mock-context fail loudly on unmatched HTTP requests?
This is a go/no-go question for adoption. If unmatched requests fall through to the real network, your acceptance suite can pass while depending on live services. Stand up a CI job with network egress blocked so pass-through is impossible rather than merely discouraged. Confirm fail-loud behavior during a timeboxed spike.
How do I mock timeouts and connection errors with macpaw/behat-http-mock-context?
The assessment lists simulating timeouts, connection errors, and malformed bodies as an open question; it may only support status and body pairs. Test those scenarios in a spike before relying on the package for failure-path coverage. If it cannot simulate them, wrap the mocking backend behind your own step definitions so it is swappable.
Is macpaw/behat-http-mock-context safe for production acceptance tests?
It is MIT licensed with a small surface area and a narrow responsibility, which makes a hard fork viable if upstream goes quiet. The risk is high because it has four stars, zero dependents, one 2024 release, and a single vendor with no evidence of external production use. Pin the version explicitly and vendor or fork it into a private namespace early. Budget for owning Guzzle and PHP dependency bumps yourself.
How should a Laravel team evaluate macpaw/behat-http-mock-context?
Run a 3-5 day timeboxed spike that proves interception against one real service class using the Http facade. Confirm fail-loud behavior on unmatched requests, build a Laravel FeatureContext bootstrap, and add 5-10 representative step definitions. Run Behat as an isolated, non-blocking CI job alongside your existing Pest suite, and decide on rollout based on interception and fail-loud results, not momentum. Wrap the package behind your own step definitions so the mocking backend is swappable.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo