Files
PeerTube/support/doc/development/tests.md
T
Chocobozzz 526f1c6df5 Rebuild thumbnail and media file architecture
* Move to sharp library to improve image manipulation performance and
   support more image formats
 * Move video previews in thumbnails directory
 * Deprecate lazy static previews endpoint
 * Plugin `getFiles()` API now includes a `width`/`height` attribute
 * Deprecate previewfile for video publication/update.
   Use `thumbnailfile` instead
 * Deprecate `thumbnailPath` and `previewPath` of `Video` in favour of
   `thumbnails`
 * Deprecate `thumbnailPath` of `VideoPlaylist` in favour of
   `thumbnails`
 * Replace `torrentPath` by `torrentFilename` and `torrentStream` for
   remote torrents for `filter:api.download.torrent.allowed.result`
   plugin filter
 * Remove useless `fileUrl` from `UserExport` and `VideoSource`
 * Remove remote captions where we don't have a valid URL
 * cache directory is not deleted on each run anymore
 * Add permanent cache for video captions and storyboards
 * Remove `cache` admin configuration, use house-keeping script instead
2026-02-13 06:20:56 +01:00

3.6 KiB

Tests

Preparation

Prepare PostgreSQL user so PeerTube can delete/create the test databases:

sudo -u postgres createuser you_username --createdb --superuser

Prepare the databases:

npm run clean:server:test

Build PeerTube:

npm run build

Server tests

Dependencies

Run docker containers needed by some test files:

sudo docker run -p 9444:9000 chocobozzz/s3-ninja
sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
sudo docker run -p 8082:8080 -e KC_BOOTSTRAP_ADMIN_USERNAME=admin -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin chocobozzz/peertube-tests-keycloak

Ensure you also have these commands:

exiftool --help
parallel --help

# For transcription tests
whisper --help
whisper-ctranslate2 --help
jiwer --help

Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):

sudo apt-get install parallel libimage-exiftool-perl
sudo pip install -r packages/tests/requirements.txt -r packages/transcription-devtools/requirements.txt

Test

To run all test suites (can be long!):

npm run test # See scripts/test.sh to run a particular suite

To run a specific test:

npm run mocha -- --exit --bail packages/tests/src/your-test.ts

# For example
npm run mocha -- --exit --bail packages/tests/src/api/videos/single-server.ts

Configuration

Some env variables can be defined to disable/enable some tests: Some env variables can be defined to disable/enable some tests:

  • DISABLE_HTTP_IMPORT_TESTS=true: disable import tests (because of youtube that could rate limit your IP)
  • DISABLE_HTTP_YOUTUBE_IMPORT_TESTS=true: disable youtube import tests (because youtube blocks CI server IP)
  • ENABLE_OBJECT_STORAGE_TESTS=true: enable object storage tests (needs chocobozzz/s3-ninja container first)
  • AKISMET_KEY: specify an Akismet key to test akismet external PeerTube plugin
  • 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
  • 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)
  • YOUTUBE_DL_DOWNLOAD_BEARER_TOKEN: bearer token to download youtube-dl binary
  • YOUTUBE_DL_PROXY: custom proxy URL for youtube-dl HTTP video import
  • AUTO_UPDATE_IMAGES: if we change image processing algorithm/quality/codecs, automatically update the image on failure

Debug server logs

While testing, you might want to display a server's logs to understand why they failed:

NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF

You can also:

  • checkout only the latest logs (PeerTube >= 5.0):
tail -n 100 test1/logs/peertube.log | npm run parse-log -- --level debug --files -
  • continuously print the latests logs (PeerTube >= 5.0):
tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files -

Client E2E tests

Local tests

To run tests on local web browsers (comment web browsers you don't have in client/e2e/wdio.local.conf.ts):

PEERTUBE2_E2E_PASSWORD=password npm run e2e:local

Browserstack tests

To run tests on browser stack:

BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack

Add E2E tests

To add E2E tests and quickly run tests using a local Chrome:

cd client/e2e
../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want