]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - support/doc/development/tests.md
Add missing tests env doc
[github/Chocobozzz/PeerTube.git] / support / doc / development / tests.md
CommitLineData
12d6b873
C
1# Tests
2
3## Preparation
4
5Prepare PostgreSQL user so PeerTube can delete/create the test databases:
6
9883e60f 7```bash
00ee545c 8sudo -u postgres createuser you_username --createdb --superuser
12d6b873
C
9```
10
11Prepare databases:
12
9883e60f 13```bash
00ee545c 14npm run clean:server:test
12d6b873
C
15```
16
17Build PeerTube:
18
9883e60f 19```bash
00ee545c 20npm run build
12d6b873
C
21```
22
23## Server tests
24
25### Dependencies
26
27Run docker containers needed by some test files:
28
9883e60f 29```bash
00ee545c
C
30sudo docker run -p 9444:9000 chocobozzz/s3-ninja
31sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
12d6b873
C
32```
33
0c058f25
C
34Ensure you also have these commands:
35
ed09acf1 36```bash
00ee545c
C
37exiftool --help
38parallel --help
ed09acf1
F
39```
40
41Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):
42```bash
00ee545c 43sudo apt-get install parallel libimage-exiftool-perl
0c058f25
C
44```
45
12d6b873
C
46### Test
47
48To run all test suites:
49
9883e60f 50```bash
00ee545c 51npm run test # See scripts/test.sh to run a particular suite
12d6b873
C
52```
53
0c058f25 54Most of tests can be run using:
12d6b873 55
9883e60f 56```bash
11e520b5 57TS_NODE_TRANSPILE_ONLY=true npm run mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/videos/video-transcoder.ts
12d6b873
C
58```
59
9883e60f
C
60`server/tests/api/activitypub` tests will need different options:
61
62```
63TS_NODE_FILES=true mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/activitypub/security.ts
64```
65
12d6b873
C
66### Configuration
67
68Some env variables can be defined to disable/enable some tests:
69
9883e60f
C
70 * `DISABLE_HTTP_IMPORT_TESTS=true`: disable import tests (because of youtube that could rate limit your IP)
71 * `ENABLE_OBJECT_STORAGE_TESTS=true`: enable object storage tests (needs `chocobozzz/s3-ninja` container first)
a4c49a17
C
72 * `AKISMET_KEY`: specify an Akismet key to test akismet external PeerTube plugin
73 * `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)
9883e60f
C
74
75
76### Debug server logs
77
78While testing, you might want to display a server's logs to understand why they failed:
79
80```bash
81NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF
82```
12d6b873 83
045224d5
F
84You can also:
85 - checkout only the latest logs (PeerTube >= 5.0):
86
87```bash
88tail -n 100 test1/logs/peertube.log | npm run parse-log -- --level debug --files -
89```
90
91 - continuously print the latests logs (PeerTube >= 5.0):
92
93```bash
94tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files -
95```
96
12d6b873
C
97
98## Client E2E tests
99
100### Local tests
101
102To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`):
103
9883e60f 104```bash
00ee545c 105PEERTUBE2_E2E_PASSWORD=password npm run e2e:local
12d6b873
C
106```
107
108### Browserstack tests
109
110To run tests on browser stack:
111
9883e60f 112```bash
00ee545c 113BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack
12d6b873 114```
6d210220
C
115
116### Add E2E tests
117
3cf68b86 118To add E2E tests and quickly run tests using a local Chrome:
6d210220 119
9883e60f 120```bash
00ee545c
C
121cd client/e2e
122../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want
6d210220 123```