pest icon indicating copy to clipboard operation
pest copied to clipboard

WebSocket client is not connected, nWidart/laravel-modules

Open parth391 opened this issue 4 months ago • 3 comments

pest: v4.1.0 pest-plugin-browser: v4.1.0

visit() don't work with laravel-modules.

Error WebSocket client is not connected is coming.

Not related to #1439, as test file is in modules/Home/tests/Browser/, visit('/') is in modules/Home/tests/Browser/HomeTest.php but still not working.

parth391 avatar Sep 22 '25 06:09 parth391

I am experiencing a similar issue.

PHP 8.3 Node v22.17.0 Relevant Composer setup:

        "pestphp/pest": "^4.0",
        "pestphp/pest-plugin-browser": "^4.1",
        "pestphp/pest-plugin-laravel": "^4.0",
        "phpunit/phpunit": "^12.0",

I've installed playwright with Chromium

npm install playwright@latest
npx playwright install
npx playwright install chromium

tests/Browser/SmokeTest.php

<?php

test('hits example', function () {
    visit('https://example.com')->assertSee('Example Domain');
});

Whether I run the tests via artist test or ./bin/pest, I get the WebSocket error.

herd php artisan test tests/Browser/SmokeTest.php

   FAIL  Tests\Browser\SmokeTest
  ⨯ hits example                                                                                                                                            4.60s  
  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Browser\SmokeTest > hits example                                                                                                 AssertionError   
  WebSocket client is not connected.

  at tests/Browser/SmokeTest.php:4
      1▕ <?php
      2▕ 
      3▕ test('hits example', function () {
  ➜   4▕     visit('https://example.com')->assertSee('Example Domain');
      5▕ });
      6▕ 


  Tests:    1 failed (1 assertions)
  Duration: 4.67s
herd php ./bin/pest tests/Browser/SmokeTest.php  
PHPUnit 12.3.15 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.25
Configuration: /Users/megseegmiller/github-codespaces/content-api/phpunit.xml

F                                                                   1 / 1 (100%)
   FAIL  Tests\Browser\SmokeTest
  ⨯ hits example                                                                                                                                            5.41s  
  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Browser\SmokeTest > hits example                                                                                                 AssertionError   
  WebSocket client is not connected.

  at tests/Browser/SmokeTest.php:4
      1▕ <?php
      2▕ 
      3▕ test('hits example', function () {
  ➜   4▕     visit('https://example.com')->assertSee('Example Domain');
      5▕ });
      6▕ 


  Tests:    1 failed (1 assertions)
  Duration: 5.51s



Time: 00:05.422, Memory: 97.00 MB

There was 1 failure:

1) P\Tests\Browser\SmokeTest::__pest_evaluable_hits_example
WebSocket client is not connected.

/Users/megseegmiller/github-codespaces/content-api/vendor/pestphp/pest-plugin-browser/src/Playwright/Client.php:75
/Users/megseegmiller/github-codespaces/content-api/vendor/pestphp/pest-plugin-browser/src/Playwright/Playwright.php:229
/Users/megseegmiller/github-codespaces/content-api/vendor/pestphp/pest-plugin-browser/src/Playwright/Playwright.php:64
/Users/megseegmiller/github-codespaces/content-api/vendor/pestphp/pest-plugin-browser/src/Api/PendingAwaitablePage.php:151
/Users/megseegmiller/github-codespaces/content-api/vendor/pestphp/pest-plugin-browser/src/Api/PendingAwaitablePage.php:45
/Users/megseegmiller/github-codespaces/content-api/tests/Browser/SmokeTest.php:4

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Any assistance with getting this running would be appreciated!

highlandmegseegmiller avatar Oct 03 '25 17:10 highlandmegseegmiller

Reason is probably this https://github.com/pestphp/pest/issues/1439

theofanisv avatar Oct 19 '25 19:10 theofanisv

@theofanisv we've both stated that it's not related to that issue. Our tests are in the Browser folder and we're not wrapping the visit() method in a different class.

highlandmegseegmiller avatar Oct 20 '25 13:10 highlandmegseegmiller