Skip to content

Asserting text when element contains duplicate spaces and vertical whitespace #8

@ziadoz

Description

@ziadoz

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions