Skip to content

Commit

Permalink
Test mystery #1 solved
Browse files Browse the repository at this point in the history
Don't try to create models before tests start, otherwise the DB connection won't be ready.
  • Loading branch information
JSn1nj4 committed Jul 7, 2024
1 parent 4999752 commit 2f8c7e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/Feature/Livewire/BlogPostTest.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

voltMountable('blog-post', ['post' => createPost()]);
voltMountable('blog-post', static fn () => ['post' => createPost()]);
12 changes: 8 additions & 4 deletions tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,16 @@ function makeUser(): User

// borrowed from Ryan Chandler:
// https://x.com/ryangjchandler/status/1808796458260341189
function livewireMountable(string $class, array $params = []): void
function livewireMountable(string $class, Closure|null $params = null): void
{
it('can be mounted', fn () => Livewire::test($class, $params)->assertOk());
it('can be mounted', function () use ($class, $params) {
Livewire::test($class, is_callable($params) ? $params() : [])->assertOk();
});
}

function voltMountable(string $component, array $params = []): void
function voltMountable(string $component, Closure|null $params = null): void
{
it('can be mounted', fn () => Volt::test($component, $params)->assertOk());
it('can be mounted', function () use ($component, $params) {
Volt::test($component, is_callable($params) ? $params() : [])->assertOk();
});
}

0 comments on commit 2f8c7e1

Please sign in to comment.