2021-09-02 02:57:59 -04:00
|
|
|
# Tests
|
|
|
|
|
|
|
|
## Preparation
|
|
|
|
|
|
|
|
Prepare PostgreSQL user so PeerTube can delete/create the test databases:
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-09-02 02:57:59 -04:00
|
|
|
$ sudo -u postgres createuser you_username --createdb --superuser
|
|
|
|
```
|
|
|
|
|
|
|
|
Prepare databases:
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-09-02 02:57:59 -04:00
|
|
|
$ npm run clean:server:test
|
|
|
|
```
|
|
|
|
|
|
|
|
Build PeerTube:
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-09-02 02:57:59 -04:00
|
|
|
$ npm run build
|
|
|
|
```
|
|
|
|
|
|
|
|
## Server tests
|
|
|
|
|
|
|
|
### Dependencies
|
|
|
|
|
|
|
|
Run docker containers needed by some test files:
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-09-02 02:57:59 -04:00
|
|
|
$ sudo docker run -p 9444:9000 chocobozzz/s3-ninja
|
|
|
|
$ sudo docker run -p 10389:10389 chocobozzz/docker-test-openldap
|
|
|
|
```
|
|
|
|
|
2022-03-07 11:16:54 -05:00
|
|
|
Ensure you also have these commands:
|
|
|
|
|
2022-08-01 09:18:50 -04:00
|
|
|
```bash
|
2022-03-07 11:16:54 -05:00
|
|
|
$ exiftool --help
|
2022-08-01 09:18:50 -04:00
|
|
|
$ parallel --help
|
|
|
|
```
|
|
|
|
|
|
|
|
Otherwise, install the packages. On Debian-based systems (like Debian, Ubuntu or Mint):
|
|
|
|
```bash
|
|
|
|
$ sudo apt-get install parallel libimage-exiftool-perl
|
2022-03-07 11:16:54 -05:00
|
|
|
```
|
|
|
|
|
2021-09-02 02:57:59 -04:00
|
|
|
### Test
|
|
|
|
|
|
|
|
To run all test suites:
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-09-02 02:57:59 -04:00
|
|
|
$ npm run test # See scripts/test.sh to run a particular suite
|
|
|
|
```
|
|
|
|
|
2022-03-07 11:16:54 -05:00
|
|
|
Most of tests can be run using:
|
2021-09-02 02:57:59 -04:00
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-12-13 05:17:49 -05:00
|
|
|
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
|
2021-09-02 02:57:59 -04:00
|
|
|
```
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
`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
|
|
|
|
```
|
|
|
|
|
2021-09-02 02:57:59 -04:00
|
|
|
### Configuration
|
|
|
|
|
|
|
|
Some env variables can be defined to disable/enable some tests:
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
* `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
|
|
|
|
```
|
2021-09-02 02:57:59 -04:00
|
|
|
|
2022-08-16 02:06:49 -04:00
|
|
|
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 -
|
|
|
|
```
|
|
|
|
|
2021-09-02 02:57:59 -04:00
|
|
|
|
|
|
|
## 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`):
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2023-02-27 04:44:32 -05:00
|
|
|
$ PEERTUBE2_E2E_PASSWORD=password npm run e2e:local
|
2021-09-02 02:57:59 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
### Browserstack tests
|
|
|
|
|
|
|
|
To run tests on browser stack:
|
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-09-02 02:57:59 -04:00
|
|
|
$ BROWSERSTACK_USER=your_user BROWSERSTACK_KEY=your_key npm run e2e:browserstack
|
|
|
|
```
|
2021-09-03 04:27:04 -04:00
|
|
|
|
|
|
|
### Add E2E tests
|
|
|
|
|
2021-12-14 11:17:01 -05:00
|
|
|
To add E2E tests and quickly run tests using a local Chrome:
|
2021-09-03 04:27:04 -04:00
|
|
|
|
2021-11-02 05:13:53 -04:00
|
|
|
```bash
|
2021-09-03 04:27:04 -04:00
|
|
|
$ cd client/e2e
|
|
|
|
$ ../node_modules/.bin/wdio wdio.local-test.conf.ts # you can also add --mochaOpts.grep to only run tests you want
|
|
|
|
```
|