Summer Sale! All accounts are 50% off this week.

eriktobben's avatar

Testing: assertSee is not performed

Hi!

I have written a test that checks if the product name is visible on the page. The problem is that the assertSee is not performed when doing the test. assertOK works.

Test

$this->actingAs($this->admin);

$product = Product::factory()->create();

$response = $this->get("/product/{$product->internal_item_number}/{$product->slug}");

$response->assertOk();
$response->assertSee($product->name);

Result

OK (1 test, 1 assertion)

If I remove $response->assertOk(), this is the result

OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Risky: 1.

So it seems that $response->assertSee($product->name) is not executed. I have used this in multiple other tests, and it has worked as expected. Is there anything I am missing here?

0 likes
2 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

If product name is empty it wont test it

dd($product->name));

What does this give you?

eriktobben's avatar

You are correct @sinnbeck . I forgot to update the factory after changing a couple of fields.

Thank you so much!

Please or to participate in this conversation.