Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Solvando's avatar

Testing Nova with Laravel Dusk

In my Nova project, I have auto-generated elements with "data-v-111112" div names. I want to use Dusk for testing from the browser but I don't know how to pass to tests their auto-generated names. Is there a way to do that?

Thank you.

0 likes
4 replies
bugsysha's avatar
bugsysha
Best Answer
Level 61

I would try something like this

Text::make('Name')
  ->withMeta([
    'extraAttributes' => [
      'dusk' => 'name',
    ]
  ])

Then you can use dusk selectors

$browser->type('@name', 'Giorgiovski');
1 like
Solvando's avatar

@bugsysha Thank you! It works in case of creating fields, but how about filters? How can I assign an attribute to them?

bugsysha's avatar

If you check the source you will see that Filter has Metable trait which has withMeta method. So I would expect same pattern to work. Have you tried it?

1 like

Please or to participate in this conversation.