From f3c67b54b608eb783a008928bc946f3c836ddc3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Fri, 15 Dec 2023 17:43:13 +0100 Subject: [PATCH] [docs] Add some testing information --- Makefile | 4 +--- docs/contributing.md | 45 ++++++++++++++++++++++++++++++++++++++------ docs/install.md | 2 +- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 0189f821..f71bc752 100644 --- a/Makefile +++ b/Makefile @@ -73,10 +73,8 @@ vendors: npm run vendors installjs: npm install -testjsfx: - firefox umap/static/umap/test/index.html testjs: node_modules - @./node_modules/mocha-phantomjs/bin/mocha-phantomjs --view 1024x768 umap/static/umap/test/index.html + @echo "See the tests at http://localhost:8001/umap/static/umap/test/" && python -m http.server 8001 tx_push: tx push -s tx_pull: diff --git a/docs/contributing.md b/docs/contributing.md index c96991a8..e66baea0 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -29,19 +29,52 @@ To be sure to install all the dev dependencies, and have everything working loca make develop ``` +#### JavaScript + +For JavaScript, here is the tooling we use: + +- Format your code with [Prettier](https://prettier.io/) +- Be sure to configure your editor to insert new lines at the end of files. + ### Hack! You can now do your changes in a specific branch, and when you're ready you can open a pull-request for us to review. -### Run tests +### Running tests Multiple tests suites are in use in the project. -| Test suite | Location | Command | -| ---------- | -------- | ------- | -| Python unit tests | `umap/tests/` | `pytest . --ignore umap/tests/integration` | -| Javascript unit tests | `umap/static/test` | `make testjs`| -| Integration tests | `umap/tests/integration` | `pytest umap/tests/integration` | + +#### Python unit tests + +```bash +pytest . --ignore umap/tests/integration +``` + +By default, the tests are run in parallel to reduce the time taken to run them. You can run them in serial mode by using the `-n1` option. + +If you only want to run one test, you can add `-k specific-test-name` to the command line. + +#### Integration tests + +```bash +pytest umap/tests/integration +``` + +The tests are using [Playwright](https://playwright.dev), which spawns a headless browser and runs the tests on it. +If the tests are failing, it might be useful to step trough the tests in the browser. This will let you go step by step with a debugger, so you can see what is happening on a real browser. + +```bash +PWDEBUG=1 pytest --headed -n1 -k specific-test-name +``` + +#### JS tests + +```bash +make testjs +``` + +These tests are located in `umap/static/test`, and we are currently using a mocha test runner. All the tests are run when you're creating a pull request, to avoid regressions. diff --git a/docs/install.md b/docs/install.md index 70b60cd6..77e36a27 100644 --- a/docs/install.md +++ b/docs/install.md @@ -168,4 +168,4 @@ pip install umap-project --upgrade umap migrate umap collectstatic umap compress -``` \ No newline at end of file +```