@@ -23,21 +23,19 @@ element-web project is fine: leave it running it a different terminal as you wou
2323when developing. Alternatively if you followed the development set up from element-web then
2424Playwright will be capable of running the webserver on its own if it isn't already running.
2525
26- The tests use Docker to launch Homeserver (Synapse or Dendrite) instances to test against, so you'll also
27- need to have Docker installed and working in order to run the Playwright tests.
26+ The tests use [ testcontainers] ( https://node.testcontainers.org/ ) to launch Homeserver (Synapse or Dendrite)
27+ instances to test against, so you'll also need to one of the
28+ [ supported container runtimes] ( #supporter-container-runtimes )
29+ installed and working in order to run the Playwright tests.
2830
2931There are a few different ways to run the tests yourself. The simplest is to run:
3032
3133``` shell
32- docker pull ghcr.io/element-hq/synapse:develop
3334yarn run test:playwright
3435```
3536
3637This will run the Playwright tests once, non-interactively.
3738
38- Note: you don't need to run the ` docker pull ` command every time, but you should
39- do it regularly to ensure you are running against an up-to-date Synapse.
40-
4139You can also run individual tests this way too, as you'd expect:
4240
4341``` shell
@@ -61,29 +59,25 @@ Some tests are excluded from running on certain browsers due to incompatibilitie
6159
6260## How the Tests Work
6361
64- Everything Playwright-related lives in the ` playwright/ ` subdirectory of react-sdk
62+ Everything Playwright-related lives in the ` playwright/ ` subdirectory
6563as is typical for Playwright tests. Likewise, tests live in ` playwright/e2e ` .
6664
67- ` playwright/plugins/homeservers ` contains Playwright plugins that starts instances
68- of Synapse/Dendrite in Docker containers. These servers are what Element-web runs
69- against in the tests.
65+ ` playwright/testcontainers ` contains the testcontainers which start instances
66+ of Synapse/Dendrite. These servers are what Element-web runs against in the tests.
7067
7168Synapse can be launched with different configurations in order to test element
72- in different configurations. ` playwright/plugins/homeserver/synapse/templates `
73- contains template configuration files for each different configuration.
74-
75- Each test suite can then launch whatever Synapse instances it needs in whatever
76- configurations.
69+ in different configurations. You can specify ` synapseConfigOptions ` as such:
7770
78- Note that although tests should stop the Homeserver instances after running and the
79- plugin also stop any remaining instances after all tests have run, it is possible
80- to be left with some stray containers if, for example, you terminate a test such
81- that the ` after() ` does not run and also exit Playwright uncleanly. All the containers
82- it starts are prefixed, so they are easy to recognise. They can be removed safely.
71+ ``` typescript
72+ test .use ({
73+ synapseConfigOptions: {
74+ // The config options to pass to the Synapse instance
75+ },
76+ });
77+ ```
8378
84- After each test run, logs from the Synapse instances are saved in ` playwright/logs/synapse `
85- with each instance in a separate directory named after its ID. These logs are removed
86- at the start of each test run.
79+ The appropriate homeserver will be launched by the Playwright worker and reused for all tests which match the worker configuration.
80+ The logs from testcontainers will be attached to any reports output from Playwright.
8781
8882## Writing Tests
8983
@@ -113,25 +107,6 @@ Homeserver instances should be reasonably cheap to start (you may see the first
113107while as it pulls the Docker image).
114108You do not need to explicitly clean up the instance as it will be cleaned up by the fixture.
115109
116- ### Synapse Config Templates
117-
118- When a Synapse instance is started, it's given a config generated from one of the config
119- templates in ` playwright/plugins/homeserver/synapse/templates ` . There are a couple of special files
120- in these templates:
121-
122- - ` homeserver.yaml ` :
123- Template substitution happens in this file. Template variables are:
124- - ` REGISTRATION_SECRET ` : The secret used to register users via the REST API.
125- - ` MACAROON_SECRET_KEY ` : Generated each time for security
126- - ` FORM_SECRET ` : Generated each time for security
127- - ` PUBLIC_BASEURL ` : The localhost url + port combination the synapse is accessible at
128- - ` localhost.signing.key ` : A signing key is auto-generated and saved to this file.
129- Config templates should not contain a signing key and instead assume that one will exist
130- in this file.
131-
132- All other files in the template are copied recursively to ` /data/ ` , so the file ` foo.html `
133- in a template can be referenced in the config as ` /data/foo.html ` .
134-
135110### Logging In
136111
137112We again heavily leverage the magic of [ Playwright fixtures] ( https://playwright.dev/docs/test-fixtures ) .
0 commit comments