Git Product home page Git Product logo

laravel-dom-assertions's People

Contributors

balping avatar helloiamlukas avatar laravel-shift avatar mabdullahsari avatar sinnbeck avatar ziadoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

laravel-dom-assertions's Issues

Is there a way to find elements containing text in array?

Hello, I couldn't find a way to solve a problem. I am writing a test where I need to find all h2 tags and see if specific text does not appear in these tags.

Can't write simple assertDontSee because p paragraph can have same text as h2.

My html tree is similar to this:

<div>
   <div>
      <h2>my h2</h2>
      <p>test</p>
   </div>
   <div>
      <h2>my h2</h2>
      <p>test</p>
   </div>
</div>

This is my test where I am trying to solve this problem

$this->actingAs($user)
            ->get(route('my-route'))
            ->assertElementExists('h2', function (AssertElement $assertElement) {
                $assertElement->doesntContainText('Specific text');
            });

Is there a way to get array of elements and use doesntContainText on all items?

Asserting text when element contains duplicate spaces and vertical whitespace

I've noticed a problem when asserting the text of an element that contains duplicate spaces and vertical whitespace:

<div>
    <p class="foobar">
        Foo
        <span>Bar</span>
    </p>
</div>
$this->assertElementExists('p.foobar', fn ($el) => $el->has('text', 'Foo Bar'));

The assertion fails because the normalised text is:

Foo
    Bar

I started adjusting Normalize::text() to replace the offending characters, but it felt like the wrong approach.

I wondered if allowing the user to supply a function to use for comparison could be a potential solution?

Not able to install on laravel 10.39

When running composer require I get a compatibility error. Seems your version of symphony/css-selector is locked to 6.0 and laravel has v. 7.0

here's the error

    - Root composer.json requires sinnbeck/laravel-dom-assertions ^1.3.1 -> satisfiable by sinnbeck/laravel-dom-assertions[v1.3.1].
    - sinnbeck/laravel-dom-assertions v1.3.1 requires symfony/css-selector ^6.0 -> found symfony/css-selector[v6.0.0-BETA1, ..., 6.4.x-dev] but it conflicts with your root composer.json require (^7.0).

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.```

Assert element does not have an attribute

I think it would make sense to have a method opposite of the has method on AssertElement to check that certain attributes are not present on an element. Maybe something like this:

$this->get('/test')
    ->assertElementExists('a', function (AssertElement $a) {
        $a->doesntHave('type', 'button');
        $a->has('href', '/foo');
    });

To be honest, this is more of a convenience thing for me, as for now I'm wrapping the element I'm testing in a <div> and using doesntContain to check for it that way but it just takes me longer to parse what my tests are doing when I come back to them at a later date :)

$this->get('/test')
    ->assertElementExists('div', function (AssertElement $div) {
        $div->doesntContain('a', [
            'type' => 'button',
        ]);

        $div->contains('a', [
            'href' => '/foo',
        ]);
    });

Assertions for datalists needed

I think this package needs a AssertDatalist class, so that we can perform assertions on the datalist.

$form->assertDatalistExists('#authors', function(AssertDatalist $datalist) {
   $datalist->hasValue('Jordan, Robert');
   $datalist->hasValues([
      'Eddings, David',
      'Jordan, Robert',
    ]);
});  

Pest Compatibility

I'm not sure if I'm just missing something, but I can't seem to get the assertions to work when testing with Pest. Anytime I try calling a method, like assertElementExists, I get this exception:

BadMethodCallException: Method Illuminate\Http\Response::assertElementExists does not exist.

I can fix that by Adding the DomAssertionsServiceProvider to getPackageProviders() in my base test case, however you have it marked as @internal which makes me feel like this isn't the right thing to do:

protected function getPackageProviders()
{
    return [
        DomAssertionsServiceProvider::class,
    ];
}

Btw, I am using this in a package test suite with Orchestra, so it might be why I need to do that in my test case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.