]>
Commit | Line | Data |
---|---|---|
12d6b873 C |
1 | # Tests |
2 | ||
3 | ## Preparation | |
4 | ||
5 | Prepare PostgreSQL user so PeerTube can delete/create the test databases: | |
6 | ||
9883e60f | 7 | ```bash |
12d6b873 C |
8 | $ sudo -u postgres createuser you_username --createdb --superuser |
9 | ``` | |
10 | ||
11 | Prepare databases: | |
12 | ||
9883e60f | 13 | ```bash |
12d6b873 C |
14 | $ npm run clean:server:test |
15 | ``` | |
16 | ||
17 | Build PeerTube: | |
18 | ||
9883e60f | 19 | ```bash |
12d6b873 C |
20 | $ npm run build |
21 | ``` | |
22 | ||
23 | ## Server tests | |
24 | ||
25 | ### Dependencies | |
26 | ||
27 | Run docker containers needed by some test files: | |
28 | ||
9883e60f | 29 | ```bash |
12d6b873 C |
30 | $ sudo docker run -p 9444:9000 chocobozzz/s3-ninja |
31 | $ sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap | |
32 | ``` | |
33 | ||
0c058f25 C |
34 | Ensure you also have these commands: |
35 | ||
36 | ``` | |
37 | $ exiftool --help | |
38 | ``` | |
39 | ||
12d6b873 C |
40 | ### Test |
41 | ||
42 | To run all test suites: | |
43 | ||
9883e60f | 44 | ```bash |
12d6b873 C |
45 | $ npm run test # See scripts/test.sh to run a particular suite |
46 | ``` | |
47 | ||
0c058f25 | 48 | Most of tests can be run using: |
12d6b873 | 49 | |
9883e60f | 50 | ```bash |
11e520b5 | 51 | TS_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 |
52 | ``` |
53 | ||
9883e60f C |
54 | `server/tests/api/activitypub` tests will need different options: |
55 | ||
56 | ``` | |
57 | TS_NODE_FILES=true mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/activitypub/security.ts | |
58 | ``` | |
59 | ||
12d6b873 C |
60 | ### Configuration |
61 | ||
62 | Some env variables can be defined to disable/enable some tests: | |
63 | ||
9883e60f C |
64 | * `DISABLE_HTTP_IMPORT_TESTS=true`: disable import tests (because of youtube that could rate limit your IP) |
65 | * `ENABLE_OBJECT_STORAGE_TESTS=true`: enable object storage tests (needs `chocobozzz/s3-ninja` container first) | |
66 | ||
67 | ||
68 | ### Debug server logs | |
69 | ||
70 | While testing, you might want to display a server's logs to understand why they failed: | |
71 | ||
72 | ```bash | |
73 | NODE_APP_INSTANCE=1 NODE_ENV=test npm run parse-log -- --level debug | less +GF | |
74 | ``` | |
12d6b873 C |
75 | |
76 | ||
77 | ## Client E2E tests | |
78 | ||
79 | ### Local tests | |
80 | ||
81 | To run tests on local web browsers (comment web browsers you don't have in `client/e2e/wdio.local.conf.ts`): | |
82 | ||
9883e60f | 83 | ```bash |
12d6b873 C |
84 | $ npm run e2e:local |
85 | ``` | |
86 | ||
87 | ### Browserstack tests | |
88 | ||
89 | To run tests on browser stack: | |
90 | ||
9883e60f | 91 | ```bash |
12d6b873 C |
92 | $ BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack |
93 | ``` | |
6d210220 C |
94 | |
95 | ### Add E2E tests | |
96 | ||
3cf68b86 | 97 | To add E2E tests and quickly run tests using a local Chrome: |
6d210220 | 98 | |
9883e60f | 99 | ```bash |
6d210220 C |
100 | $ cd client/e2e |
101 | $ ../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want | |
102 | ``` |