Weave Code
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

Httptest Laravel Package

jcchavezs/httptest

Spin up a lightweight local HTTP server for integration testing real HTTP calls (e.g., cURL). Define a request handler to assert method/headers/body and craft responses, enabling client- and server-side assertions without mocking HTTP.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Accelerating API/HTTP integration testing: Enables rapid validation of HTTP endpoints (REST, GraphQL, etc.) without relying on external services (e.g., Postman, manual cURL). Reduces flakiness in CI/CD pipelines by mocking or replaying HTTP interactions.
  • Build vs. Buy: Justifies not building a custom HTTP testing framework (e.g., for startups or teams with limited QA resources). Avoids reinventing wheel for common needs like:
    • Asserting request/response cycles.
    • Simulating edge cases (timeouts, malformed payloads).
    • Testing middleware/auth flows.
  • Roadmap prioritization:
    • Phase 1: Integrate into existing Laravel test suites to replace brittle Http::fake() or manual assertions.
    • Phase 2: Extend to test cross-service interactions (e.g., microservices) by mocking external APIs.
    • Phase 3: Use for contract testing (e.g., validating API schemas against responses).
  • Use cases:
    • Laravel monoliths: Replace Http::fake() for more expressive assertions (e.g., "this endpoint must return a 401 when auth fails").
    • Microservices: Mock dependencies (e.g., payment gateways) to isolate unit tests.
    • Legacy systems: Test HTTP wrappers around SOAP/XML APIs without external tooling.

When to Consider This Package

  • Adopt if:

    • Your stack is Laravel/PHP and you test HTTP layers (APIs, webhooks, or service integrations).
    • You need lightweight, code-based HTTP assertions (vs. GUI tools like Postman or Insomnia).
    • Your team lacks dedicated QA resources but needs reproducible, automated HTTP tests.
    • You’re testing authentication flows (e.g., OAuth, JWT) or middleware (e.g., rate limiting).
    • You want to avoid flaky tests caused by external API dependencies (e.g., Stripe, Twilio).
  • Look elsewhere if:

    • You need modern HTTP testing (last release in 2018; consider alternatives like Pest HTTP or Laravel Dusk).
    • Your use case requires GraphQL-specific testing (this package is HTTP-agnostic).
    • You’re testing browser interactions (use Laravel Dusk or Playwright instead).
    • You need performance testing (use k6 or Gatling).
    • Your team prefers DSL-based tools (e.g., Karate, RestAssured).

How to Pitch It (Stakeholders)

For Executives: *"This package lets our engineering team automate and accelerate HTTP API testing without relying on manual tools or external services. By integrating it into our Laravel test suite, we can:

  • Reduce CI/CD failures from flaky external API calls (e.g., payment gateways) by mocking responses.
  • Cut QA costs by shifting from manual testing to automated assertions in PHP.
  • Improve security testing by validating auth flows (e.g., JWT/OAuth) programmatically.
  • Future-proof our stack with a lightweight, maintainable solution (vs. building custom tools).

Risk: The package is unmaintained (last release 2018), but its core functionality is stable for basic HTTP testing. We’d mitigate this by:

  1. Vetting alternatives (e.g., Pest HTTP) if we need GraphQL or modern features.
  2. Wrapping it in a custom service layer to isolate changes.
  3. Prioritizing it for internal API validation (low-risk use case) before broader adoption."*

For Engineering: *"httptest is a minimalist PHP library to assert HTTP interactions in Laravel tests. Key benefits:

  • Replace Http::fake(): More expressive assertions (e.g., assertRequestCount(2) + payload validation).
  • Mock external APIs: Isolate tests from flaky dependencies (e.g., Stripe, Twilio).
  • Test auth/middleware: Verify 401s, rate limits, or custom headers without hitting real services.
  • Integrates with Laravel’s test helpers: Works alongside TestCase, RefreshDatabase, etc.

Example use case:

// Test a payment webhook
$response = $this->post('/webhook/payment', ['amount' => 100]);
httptest()->assertRequest()
    ->wasSentTo('/stripe/confirm')
    ->withHeaders(['Authorization' => 'Bearer token'])
    ->withJson(['amount' => 100]);

Tradeoffs:

  • No GraphQL support (use Laravel GraphQL tools instead).
  • Unmaintained (but core functionality is stable; we’d monitor for forks or alternatives).
  • Not for E2E testing (use Dusk/Playwright for browser flows).

Proposal: Pilot this for internal API contract testing (e.g., service-to-service calls) before expanding to external integrations."*

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.
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager