# Fake an HTTP call a Vue page depends on

> Http::fake stubs the outbound request. The Inertia test asserts the prop. It does not call the real host.

- URL: https://laravel-vuejs.space/laravel-http-fake-test-vue
- Author: Anass Ez-zouaine (https://laravel-vuejs.space/author/anass-ez-zouaine)
- Published: 2026-10-11
- Topics: Laravel, VueJs, Testing

People searching “Laravel Http::fake” hit the real API from a Pest test because the URL in the fake did not match. The [tests guide](https://laravel-vuejs.space/test-laravel-vue) is the Inertia assertion. This page is the outbound stub.

> **TL;DR**
>
> -   Http::fake stubs the outbound request.
> -   The Inertia test asserts the prop.
> -   It does not call the real host.
> -   Do not `Http::fake()` with no argument and then assert the prop equals the real city’s name.
>
> **Who it's for:** Laravel + Vue developers
>
> **Applies to:** Laravel 13 · Vue 3

## The fix

```php
use Illuminate\Support\Facades\Http;

Http::fake([
    'https://maps.example/*' => Http::response(['label' => 'Rabat'], 200),
]);

$this->actingAs($user)
    ->get('/posts/create')
    ->assertOk();
```

The controller calls `Http::get('https://maps.example/place')` and passes `label` as a prop. The test never opens a socket. If the pattern does not match, Http throws or calls the network, depending on `Http::preventStrayRequests()`.

```php
Http::preventStrayRequests();
```

That line fails the test when a URL is not faked. Use it.

## What to avoid

> **Gotcha**
>
> Do not `Http::fake()` with no argument and then assert the prop equals the real city’s name. An empty fake returns 200 and an empty body. Do not disable TLS verification so the test can “just hit staging”.

## FAQ

**Q: How do I fake an HTTP call a Vue page depends on?**

Http::fake stubs the outbound request. The Inertia test asserts the prop. It does not call the real host.

**Q: What goes wrong with Laravel Http::fake?**

Many developers hit the real API from a Pest test because the URL in the fake did not match. Do not `Http::fake()` with no argument and then assert the prop equals the real city's name.
