ニジカ投稿局 https://tv.nizika.tv
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.

tests.md 3.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # Tests
  2. ## Preparation
  3. Prepare PostgreSQL user so PeerTube can delete/create the test databases:
  4. ```bash
  5. sudo -u postgres createuser you_username --createdb --superuser
  6. ```
  7. Prepare the databases:
  8. ```bash
  9. npm run clean:server:test
  10. ```
  11. Build PeerTube:
  12. ```bash
  13. npm run build
  14. ```
  15. ## Server tests
  16. ### Dependencies
  17. Run docker containers needed by some test files:
  18. ```bash
  19. sudo docker run -p 9444:9000 chocobozzz/s3-ninja
  20. sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
  21. ```
  22. Ensure you also have these commands:
  23. ```bash
  24. exiftool --help
  25. parallel --help
  26. # For transcription tests
  27. whisper --help
  28. whisper-ctranslate2 --help
  29. jiwer --help
  30. ```
  31. Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):
  32. ```bash
  33. sudo apt-get install parallel libimage-exiftool-perl
  34. sudo pip install -r packages/tests/requirements.txt -r packages/transcription-devtools/requirements.txt
  35. ```
  36. ### Test
  37. To run all test suites (can be long!):
  38. ```bash
  39. npm run test # See scripts/test.sh to run a particular suite
  40. ```
  41. To run a specific test:
  42. ```bash
  43. npm run mocha -- --exit --bail packages/tests/src/your-test.ts
  44. # For example
  45. npm run mocha -- --exit --bail packages/tests/src/api/videos/single-server.ts
  46. ```
  47. ### Configuration
  48. Some env variables can be defined to disable/enable some tests:
  49. * `DISABLE_HTTP_IMPORT_TESTS=true`: disable import tests (because of youtube that could rate limit your IP)
  50. * `ENABLE_OBJECT_STORAGE_TESTS=true`: enable object storage tests (needs `chocobozzz/s3-ninja` container first)
  51. * `AKISMET_KEY`: specify an Akismet key to test akismet external PeerTube plugin
  52. * `OBJECT_STORAGE_SCALEWAY_KEY_ID` and `OBJECT_STORAGE_SCALEWAY_ACCESS_KEY`: specify Scaleway API keys to test object storage ACL (not supported by our `chocobozzz/s3-ninja` container)
  53. * `ENABLE_FFMPEG_THUMBNAIL_PIXEL_COMPARISON_TESTS=true`: enable pixel comparison on images generated by ffmpeg. Disabled by default because a custom ffmpeg version may fails the tests
  54. ### Debug server logs
  55. While testing, you might want to display a server's logs to understand why they failed:
  56. ```bash
  57. NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF
  58. ```
  59. You can also:
  60. - checkout only the latest logs (PeerTube >= 5.0):
  61. ```bash
  62. tail -n 100 test1/logs/peertube.log | npm run parse-log -- --level debug --files -
  63. ```
  64. - continuously print the latests logs (PeerTube >= 5.0):
  65. ```bash
  66. tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files -
  67. ```
  68. ## Client E2E tests
  69. ### Local tests
  70. To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`):
  71. ```bash
  72. PEERTUBE2_E2E_PASSWORD=password npm run e2e:local
  73. ```
  74. ### Browserstack tests
  75. To run tests on browser stack:
  76. ```bash
  77. BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack
  78. ```
  79. ### Add E2E tests
  80. To add E2E tests and quickly run tests using a local Chrome:
  81. ```bash
  82. cd client/e2e
  83. ../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want
  84. ```