You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # End to end tests
  2. E2e tests largely follow the same syntax as [integration tests](../integration).
  3. Whereas integration tests are intended to mock and stress the back-end, server-side code, e2e tests the interface between front-end and back-end, as well as visual regressions with both assertions and visual comparisons.
  4. They can be run with make commands for the appropriate backends, namely:
  5. ```shell
  6. make test-sqlite
  7. make test-pgsql
  8. make test-mysql
  9. make test-mysql8
  10. make test-mssql
  11. ```
  12. Make sure to perform a clean front-end build before running tests:
  13. ```
  14. make clean frontend
  15. ```
  16. ## Install playwright system dependencies
  17. ```
  18. npx playwright install-deps
  19. ```
  20. ## Run all tests via local act_runner
  21. ```
  22. act_runner exec -W ./.github/workflows/pull-e2e-tests.yml --event=pull_request --default-actions-url="https://github.com" -i catthehacker/ubuntu:runner-latest
  23. ```
  24. ## Run sqlite e2e tests
  25. Start tests
  26. ```
  27. make test-e2e-sqlite
  28. ```
  29. ## Run MySQL e2e tests
  30. Setup a MySQL database inside docker
  31. ```
  32. docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest #(just ctrl-c to stop db and clean the container)
  33. docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --rm --name elasticsearch elasticsearch:7.6.0 #(in a second terminal, just ctrl-c to stop db and clean the container)
  34. ```
  35. Start tests based on the database container
  36. ```
  37. TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-e2e-mysql
  38. ```
  39. ## Run pgsql e2e tests
  40. Setup a pgsql database inside docker
  41. ```
  42. docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container)
  43. ```
  44. Start tests based on the database container
  45. ```
  46. TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-e2e-pgsql
  47. ```
  48. ## Run mssql e2e tests
  49. Setup a mssql database inside docker
  50. ```
  51. docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container)
  52. ```
  53. Start tests based on the database container
  54. ```
  55. TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-e2e-mssql
  56. ```
  57. ## Running individual tests
  58. Example command to run `example.test.e2e.js` test file:
  59. _Note: unlike integration tests, this filtering is at the file level, not function_
  60. For SQLite:
  61. ```
  62. make test-e2e-sqlite#example
  63. ```
  64. For other databases(replace `mssql` to `mysql`, `mysql8` or `pgsql`):
  65. ```
  66. TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-e2e-mssql#example
  67. ```
  68. ## Visual testing
  69. Although the main goal of e2e is assertion testing, we have added a framework for visual regress testing. If you are working on front-end features, please use the following:
  70. - Check out `main`, `make clean frontend`, and run e2e tests with `VISUAL_TEST=1` to generate outputs. This will initially fail, as no screenshots exist. You can run the e2e tests again to assert it passes.
  71. - Check out your branch, `make clean frontend`, and run e2e tests with `VISUAL_TEST=1`. You should be able to assert you front-end changes don't break any other tests unintentionally.
  72. VISUAL_TEST=1 will create screenshots in tests/e2e/test-snapshots. The test will fail the first time this is enabled (until we get visual test image persistence figured out), because it will be testing against an empty screenshot folder.
  73. ACCEPT_VISUAL=1 will overwrite the snapshot images with new images.