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