blob: 6eb499f0c79139e14b1096f3b4d8f960267d4adf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# Tests
## Preparation
Prepare PostgreSQL user so PeerTube can delete/create the test databases:
```bash
$ sudo -u postgres createuser you_username --createdb --superuser
```
Prepare databases:
```bash
$ npm run clean:server:test
```
Build PeerTube:
```bash
$ npm run build
```
## Server tests
### Dependencies
Run docker containers needed by some test files:
```bash
$ sudo docker run -p 9444:9000 chocobozzz/s3-ninja
$ sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
```
Ensure you also have these commands:
```bash
$ exiftool --help
$ parallel --help
```
Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):
```bash
$ sudo apt-get install parallel libimage-exiftool-perl
```
### Test
To run all test suites:
```bash
$ npm run test # See scripts/test.sh to run a particular suite
```
Most of tests can be run using:
```bash
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
```
`server/tests/api/activitypub` tests will need different options:
```
TS_NODE_FILES=true mocha -- --timeout 30000 --exit -r ts-node/register -r tsconfig-paths/register --bail server/tests/api/activitypub/security.ts
```
### Configuration
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)
* `ENABLE_OBJECT_STORAGE_TESTS=true`: enable object storage tests (needs `chocobozzz/s3-ninja` container first)
### Debug server logs
While testing, you might want to display a server's logs to understand why they failed:
```bash
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):
```bash
tail -n 100 test1/logs/peertube.log | npm run parse-log -- --level debug --files -
```
- continuously print the latests logs (PeerTube >= 5.0):
```bash
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`):
```bash
$ PEERTUBE2_E2E_PASSWORD=password npm run e2e:local
```
### Browserstack tests
To run tests on browser stack:
```bash
$ 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:
```bash
$ cd client/e2e
$ ../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want
```
|