Dusk: jQuery requirement

Created on 17 Jan 2017  路  3Comments  路  Source: laravel/dusk

Hello,

The following line:

var link = $("{$selector}");

in Laravel\Dusk\Concerns\MakesAssertions's seeLink() function is problematic for projects that do not use jQuery as developers will be presented with Facebook\WebDriver\Exception\UnknownServerException: unknown error: $ is not defined.

Would it be possible to remove the jQuery dependency with native javascript?

Most helpful comment

I know this is closed, but I think one should use vanilla JS instead of pulling in JQuery. JQuery might break, in rare cases, someones application, and it's a lot of JS just to grab a link.

All 3 comments

Hacking on it a bit and it's possible to do something like:

$script = <<<JS
            return Array.prototype.slice.call(document.querySelectorAll('a')).some(function(element){return element.innerHTML === '$link'});
JS;

I can work on a PR if you think it's worth it.

I know this is closed, but I think one should use vanilla JS instead of pulling in JQuery. JQuery might break, in rare cases, someones application, and it's a lot of JS just to grab a link.

If someone can PR a Vanilla JS implementation that works in a sample test I will merge it.

Was this page helpful?
0 / 5 - 0 ratings