[Bug]: Coverage for Livewire v4 SFC/MFC not working

Open
#1,619 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
php
Domain
testing

Research direction

Start with the Pest configuration extending TestCase and including ../resources/views/**, then reproduce the issue with ./vendor/bin/pest --coverage after creating the Livewire MFC with php artisan make:livewire post.create --mfc --test. Trace how coverage discovers the new component files and compare the result with the tests that run successfully. Done means coverage output includes the newly created Livewire v4 component.

Written by the indexing model from the issue text.

Description

bug
What Happened

Hi everyone, I migrated my project from livewire v3 to livewire v4, using the brand new structure for components (see https://livewire.laravel.com/docs/4.x/components#multi-file-components).

With the correct configuration, the pest tests are running fine, but adding the --coverage flag, no information about the coverage is displayed for the new livewire v4 components.

I asked on the livewire repo (see https://github.com/livewire/livewire/discussions/9601), and they redirected me here to raise an issue about this.

How to Reproduce

Brand new install with Laravel and Livewire v4 (https://livewire.laravel.com/docs/4.x/quickstart).
Then create a component with : php artisan make:livewire post.create --mfc --test
In the pest config, update it with this :

pest()->extend(TestCase::class)
    ->use(RefreshDatabase::class)
    ->in('Feature', 'Unit', '../resources/views/**');

then run you tests with : ./vendor/bin/pest --coverage

You'll see that the coverage for your newly created component is missing but the tests ran well.

Sample Repository

No response

Pest Version

v4.3.1

PHP Version

8.5.1

Operation System

Linux

Notes

No response

Dominant language
PHP
Stars
11.7k
Forks
538
Avg merge
4d 11h
Merged PRs (30d)
8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pestphp/pest

All issues in pestphp/pest

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.