Add testing docs (#439)

* Add testing docs

* Update
This commit is contained in:
Jaime Oyarzún Knittel
2021-07-01 02:13:18 -07:00
committed by acywatson
parent b5e36c660b
commit 92216a34e9
3 changed files with 43 additions and 1 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
lint-staged
npx lint-staged

View File

@ -82,6 +82,7 @@ function Editor() {
## Documentation
- [How Outline was designed](/docs/design.md)
- [Testing](/docs/testing.md)
## Contributing

41
docs/testing.md Normal file
View File

@ -0,0 +1,41 @@
# Testing
Outline relies on tests to ensure that changes don't break anything, using a mix of unit and end-to-end tests.
## Unit tests
We use Jest to run unit tests in core (`outline` package). The goal is to have a well tested API, enabling us to add or modify features without breaking it.
To run the tests use:
```
npm run test-unit
```
Unit tests can be found in [this directory](/packages/outline/src/__tests__).
## End-to-end (E2E) tests
We use [Playwright](https://playwright.dev/) for running E2E tests in Chromium, Firefox and WebKit.
These tests run in the `outline-playground` package and are divided into proactive and reactive tests (`e2e` and `regression` directories).
The goal for this type of test is to validate the behavior of Outline in a browser, without necessarily knowing how the internals work.
To run E2E tests use:
```
npm run start &
npm run test-e2e:chromium # or :firefox, :webkit
```
E2E tests can be found in [this directory](/packages/outline-playground/__tests__)
## General guidelines
When writing tests, please follow these practices:
- New features must include tests.
- No test is too small or too big to be included. If it can break, add a test.
- Do not merge pull requests with failing tests, this can block other people and releases.
- Be mindful with your abstractions: sometimes it's convenient to create abstractions/utils to make test files smaller and less repetitive. Please make sure that they are simple and easy to follow.