]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - support/doc/development/tests.md
Update release.md process
[github/Chocobozzz/PeerTube.git] / support / doc / development / tests.md
... / ...
CommitLineData
1# Tests
2
3## Preparation
4
5Prepare PostgreSQL user so PeerTube can delete/create the test databases:
6
7```bash
8$ sudo -u postgres createuser you_username --createdb --superuser
9```
10
11Prepare databases:
12
13```bash
14$ npm run clean:server:test
15```
16
17Build PeerTube:
18
19```bash
20$ npm run build
21```
22
23## Server tests
24
25### Dependencies
26
27Run docker containers needed by some test files:
28
29```bash
30$ sudo docker run -p 9444:9000 chocobozzz/s3-ninja
31$ sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
32```
33
34Ensure you also have these commands:
35
36```bash
37$ exiftool --help
38$ parallel --help
39```
40
41Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):
42```bash
43$ sudo apt-get install parallel libimage-exiftool-perl
44```
45
46### Test
47
48To run all test suites:
49
50```bash
51$ npm run test # See scripts/test.sh to run a particular suite
52```
53
54Most of tests can be run using:
55
56```bash
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
58```
59
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
66### Configuration
67
68Some env variables can be defined to disable/enable some tests:
69
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)
72
73
74### Debug server logs
75
76While testing, you might want to display a server's logs to understand why they failed:
77
78```bash
79NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF
80```
81
82You can also:
83 - checkout only the latest logs (PeerTube >= 5.0):
84
85```bash
86tail -n 100 test1/logs/peertube.log | npm run parse-log -- --level debug --files -
87```
88
89 - continuously print the latests logs (PeerTube >= 5.0):
90
91```bash
92tail -f test1/logs/peertube.log | npm run parse-log -- --level debug --files -
93```
94
95
96## Client E2E tests
97
98### Local tests
99
100To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`):
101
102```bash
103$ npm run e2e:local
104```
105
106### Browserstack tests
107
108To run tests on browser stack:
109
110```bash
111$ BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack
112```
113
114### Add E2E tests
115
116To add E2E tests and quickly run tests using a local Chrome:
117
118```bash
119$ cd client/e2e
120$ ../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want
121```