-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Has anyone tried using Pest with this package ? #52
Comments
I don't use pest much yet, but I know @DanielCoulbourne does. Daniel—have you used modular in Pest codebases? My guess is that you need to update |
I've used Pest with Modular, I set the modules path in <testsuite name="Modules">
<directory>app-modules/*/Tests/Feature</directory>
<directory>app-modules/*/Tests/Unit</directory>
</testsuite> My TestCase.php looks like: abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use LazilyRefreshDatabase;
} Then I import the test case into Pest.php No namespaces or class is required. use Tests\TestCase;
uses(
TestCase::class,
)->in(__DIR__); Then in a module I have import <?php
use Dcblogdev\Contacts\Models\Contact;
uses(Tests\TestCase::class);
test('can see contacts', function () {
Contact::factory()->count(10)->create();
$this->assertDatabaseCount('contacts', 10);
$this->get('contacts')->assertOk();
});
test('can create a contact', function () {
$this->post('contacts', [
'name' => 'test',
])->assertRedirect('contacts');
$this->assertDatabaseCount('contacts', 1);
}); |
I have almost the same settings. The Test file <?php
use Tests\TestCase;
uses(TestCase::class);
test('that true is true', function () {
expect(true)->toBeTrue();
}); and when I run the tests, I get following output PASS Modules\hmspost\tests\Unit\ExampleTest
✓ that true is true 0.05s I changed the Example Feature test to following <?php
namespace Talkad\HmsPost\Tests\Feature;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/** @test */
public function the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
} and I get following output PASS Talkad\HmsPost\Tests\Feature\ExampleTest
✓ the application returns a successful response 0.07s
|
just run this code before on terminal php artisan modules:sync |
I think this is a much better solution // in the root project test/Pest.php
uses(TestCase::class, RefreshDatabase::class)->in('Feature', '../app-modules/*/tests'); instead of including the |
Confirm, this is working in a fresh Laravel 11 installation. |
Is anyone else have problems with test outside modules? The tests in the default
|
did you add it manuallly or by running |
I almost dare not say it, but my problem was that the |
I am trying this package to modularise one of our application. I have configured Laravel to use pest for testing.
In the main Laravel tree, I have tests/Pest.php configuration file.
I am creating modules in
modules
directory instead ofapp-modules
. The namespace is set to Talkad.I have created a module called
hms-post
.When I run pest, I see
Modules\hmspost\tests\Unit\ExampleTest
instead ofTalkad\HmsPost\Tests\Unit\ExampleTest
The ExampleTest (modules/hms-post/tests/Unit/ExampleTest.php)
The Pest configuration
tests/Pest.php under the main Laravel tree
Need help on this.
The text was updated successfully, but these errors were encountered: