Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Browser plugin - assertUrlIs does not follow documentation #1607

@Jamesking56

Description

@Jamesking56

What Happened

When using assertUrlIs() function on a browser page, the docs state you can use it as follows:

->assertUrlIs('/login');

But you cannot use it like this because the regex is errorneously prepending the ^ character, this means the full URL must start with /login with nothing preceding it. This makes the test always fail for example:

Actual URL [http://127.0.0.1:48701/login] does not equal expected URL [/login].
Failed asserting that 'http://127.0.0.1:48701/login' matches PCRE pattern "/^\/login$/u".

For this to work currently, you have to use the full URL inside your test, which is obviously silly due to the fact that the port number may always change between runs.

Removing the ^ preceding character does fix this issue.

How to Reproduce

Install a fresh Laravel app, install Pest and Pest Browser Plugin, then add a test which asserts what the URL is (e.g. ->assertUrlIs('/login');), Make sure the test would pass (make your app render that URL correctly and visit that page)

Run the test and see that it fails.

Sample Repository

No response

Pest Version

4.3.1

PHP Version

8.4.16

Operation System

Linux

Notes

pestphp/pest-plugin-browser version v4.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions