Skip to content

Conversation

@dunglas
Copy link
Member

@dunglas dunglas commented Aug 21, 2019

Easily test applications using Mercure, WebSocket and similar technologies with Panther!

This PR introduces a new method to create additional extra, isolated, browsers; that can interact with the primary one. For instance, it can be useful to test a chat application:

use Symfony\Component\Panther\PantherTestCase;

class ChatTest extends PantherTestCase
{
    public function testMultiClient(): void
    {

        $client1 = self::createPantherClient()
        $client1->request('GET', '/chat'); 
        // Connect a 2nd user, using an isolated browser
        $crawler2 = self::createAdditionalPantherClient()->request('GET', '/chat');

        // Say hi
        $crawler2->submitForm('Post message', ['message' => 'Hi folks']);

        // Wait for the message to be propagated
        $client1->waitFor('.message');
        $this->assertSelectorTextContains('.message', 'Hi folks'); // Assertions are always executed in the PRIMARY browser; but you can use the crawler of the other browsers directly if needed
    }
}

@dunglas dunglas force-pushed the multi-clients branch 2 times, most recently from 076beaf to 1f5498e Compare August 21, 2019 22:50
@dunglas
Copy link
Member Author

dunglas commented Aug 22, 2019

Merged in f5f377f. It looks like a GitHub bug occurred, that prevents this PR to be marked as merged.

@dunglas dunglas closed this Aug 22, 2019
@dunglas dunglas deleted the multi-clients branch August 22, 2019 09:19
dunglas added a commit to dunglas/panthere that referenced this pull request Aug 22, 2019
Mercure and WebSocket testing: allow to create several browser instances
dunglas added a commit that referenced this pull request Dec 28, 2020
Mercure and WebSocket testing: allow to create several browser instances
nicolas-grekas pushed a commit that referenced this pull request Jan 18, 2021
Mercure and WebSocket testing: allow to create several browser instances
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant