Laravel 10应用PHPUnit测试报“Latest compiled component path not found”错误修复
Laravel 10 + Livewire 3 + Breeze 测试报错:Latest compiled component path not found
我有一个基于Laravel 10、Laravel Breeze和Livewire 3的应用,运行PHPUnit预定义测试时遇到如下错误:
FAILED Tests\Feature\Auth\AuthenticationTest > navigation menu can be rendered Expected response status code [200] but received 500. Failed asserting that 500 is identical to 200. The following exception occurred during the last request: Exception: Latest compiled component path not found. Latest compiled component path not found. at tests/Feature/Auth/AuthenticationTest.php:67 63▕ 64▕ $response = $this->get('/dashboard'); 65▕ 66▕ $response ➜ 67▕ ->assertOk() 68▕ ->assertSeeVolt('layout.navigation'); 69▕ }
通过composer show livewire/livewire确认Livewire已正确安装,版本信息如下:
name : livewire/livewire descrip. : A front-end framework for Laravel. keywords : versions : * v3.4.6 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : source : [git] https://github.com/livewire/livewire.git 7e7d638183b34fb61621455891869f5abfd55a82 dist : [zip] https://api.github.com/repos/livewire/livewire/zipball/7e7d638183b34fb61621455891869f5abfd55a82 7e7d638183b34fb61621455891869f5abfd55a82 path : /var/www/projectmanagement/vendor/livewire/livewire names : livewire/livewire support issues : https://github.com/livewire/livewire/issues source : https://github.com/livewire/livewire/tree/v3.4.6 autoload files psr-4 Livewire\ => src/ requires illuminate/database ^10.0|^11.0 illuminate/routing ^10.0|^11.0 illuminate/support ^10.0|^11.0 illuminate/validation ^10.0|^11.0 league/mime-type-detection ^1.9 php ^8.1 symfony/http-kernel ^6.2|^7.0 requires (dev) calebporzio/sushi ^2.1 laravel/framework ^10.0|^11.0 laravel/prompts ^0.1.6 mockery/mockery ^1.3.1 orchestra/testbench 8.20.0|^9.0 orchestra/testbench-dusk 8.20.0|^9.0 phpunit/phpunit ^10.4 psy/psysh ^0.11.22|^0.12
当前phpunit.xml配置内容如下:
<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" > <testsuites> <testsuite name="Unit"> <directory>tests/Unit</directory> </testsuite> <testsuite name="Feature"> <directory>tests/Feature</directory> </testsuite> </testsuites> <source> <include> <directory>app</directory> </include> </source> <php> <env name="APP_ENV" value="testing"/> <env name="BCRYPT_ROUNDS" value="4"/> <env name="CACHE_DRIVER" value="array"/> <!-- <env name="DB_CONNECTION" value="sqlite"/> --> <!-- <env name="DB_DATABASE" value=":memory:"/> --> <env name="MAIL_MAILER" value="array"/> <env name="PULSE_ENABLED" value="false"/> <env name="QUEUE_CONNECTION" value="sync"/> <env name="SESSION_DRIVER" value="array"/> <env name="TELESCOPE_ENABLED" value="false"/> </php> </phpunit>
已知该问题可能与Livewire组件的key有关,但目前没有明确解决方案。请问是否需要修改PHPUnit配置来解决这个问题?
内容的提问来源于stack exchange,提问作者Petitemo
相关产品推荐
相关产品推荐

