element-web-Github/test/end-to-end-tests
Matthew Hodgson b8b5dd82aa
Triple the speed of E2E tests and stop them exploding if a circular datastructure is logged (#8095)
* stop e2e tests exploding if a circular datastructure is logged

it's valid for the webapp to log datastructures to the console which happen to be circular
but the e2e test running explodes badly with a runtime exception and bombs out before
logging anything or providing a sensible stacktrace. you can trap the exception though and
get a sensible error however.

* don't barf on circular refs in return vals either

and log timestamps

* log timestamps

* speed up roomDir & E2EE tests by 3x

use timeouts correctly, so the first set
of scenarios take 42s to run rather than 2m21s

* speed up space test by 20s
2022-03-21 10:26:26 +00:00
..
element Fix end-to-end tests (synapse setup) (#7420) 2021-12-21 02:12:07 +00:00
src Triple the speed of E2E tests and stop them exploding if a circular datastructure is logged (#8095) 2022-03-21 10:26:26 +00:00
synapse Use the shared secret registration API directly (#7774) 2022-02-11 17:03:22 +00:00
.gitignore Convert end-to-end tests to Typescript (#7206) 2021-12-06 09:59:06 +11:00
has-custom-app.js Fix spacing errors (#7484) 2022-01-10 12:57:20 +00:00
install.sh Do not generate a lockfile when running in CI 2021-07-07 16:11:47 +02:00
package.json Add an e2e test to check the app reloads when a new version is available (#7956) 2022-03-03 15:44:34 +00:00
README.md Triple the speed of E2E tests and stop them exploding if a circular datastructure is logged (#8095) 2022-03-21 10:26:26 +00:00
run.sh Use the shared secret registration API directly (#7774) 2022-02-11 17:03:22 +00:00
start.ts Improve end-to-end test logging by rendering JSHandles (#7959) 2022-03-03 07:59:29 -07:00
TODO.md move everything to subfolder to merge into react-sdk 2019-10-09 16:52:48 +02:00
tsconfig.json Convert end-to-end tests to Typescript (#7206) 2021-12-06 09:59:06 +11:00
Windows.md Add support for redirecting to external pages after logout (#7905) 2022-03-01 11:06:17 -07:00
yarn.lock Add an e2e test to check the app reloads when a new version is available (#7956) 2022-03-03 15:44:34 +00:00

Matrix React SDK End-to-End tests

This directory contains tests for matrix-react-sdk. The tests fire up a headless Chrome and simulate user interaction (end-to-end). Note that end-to-end has little to do with the end-to-end encryption Matrix supports, just that we test the full stack, going from user interaction to expected DOM in the browser.

Setup

Run ./install.sh. This will:

  • install Synapse, fetches the develop branch at the moment. If anything fails here, please refer to the Synapse README to see if you're missing one of the prerequisites.
  • install Element Web, this fetches the develop branch at the moment.
  • install dependencies (will download copy of Chrome)

Running the tests

Run tests with ./run.sh.

Debug tests locally.

./run.sh will run the tests against the Element copy present in element/element-web served by a static Python HTTP server. You can symlink your element-web develop copy here but that doesn't work well with Webpack recompiling. You can run the test runner directly and specify parameters to get more insight into a failure or run the tests against your local Webpack server.

./synapse/stop.sh && \
./synapse/start.sh && \
node start.js <parameters>

It's important to always stop and start Synapse before each run of the tests to clear the in-memory SQLite database it uses, as the tests assume a blank slate.

start.js accepts these parameters (and more, see node start.js --help) that can help running the tests locally:

  • --app-url <url> don't use the Element Web copy and static server provided by the tests, but use a running server like the Webpack watch server to run the tests against.
  • --slow-mo type at a human speed, useful with --windowed.
  • --throttle-cpu <factor> throttle cpu in the browser by the given factor. Useful to reproduce failures because of insufficient timeouts happening on the slower CI server.
  • --windowed run the tests in an actual browser window Try to limit interacting with the windows while the tests are running. Hovering over the window tends to fail the tests, dragging the title bar should be fine though.
  • --dev-tools open the devtools in the browser window, only applies if --windowed is set as well.

For god level debug (e.g. for debugging slow tests):

env DEBUG="puppeteer:*" ./test/end-to-end-tests/run.sh --app-url http://localhost:8080 --log-directory pwd/logs --dev-tools --windowed 2>&1 | cat

(piping everything through cat means you get proper timestamps on the debugging, and the chromiums hang around at the end)

Developer Guide

Please follow the standard Matrix contributor's guide: https://github.com/matrix-org/synapse/tree/master/CONTRIBUTING.rst

Please follow the Matrix JS/React code style as per: https://github.com/matrix-org/matrix-react-sdk/blob/master/code_style.md