diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66bd623c..07df5fe7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,6 +44,9 @@ jobs: - name: Run smoke test run: VERBOSE=1 DEBUG=1 MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:smoke + - name: Run python tests + run: yarn run test:python + - name: Run main tests run: MOCHA_WEBDRIVER_HEADLESS=1 yarn run test diff --git a/README.md b/README.md index 10ebbf23..48a1fd9f 100644 --- a/README.md +++ b/README.md @@ -291,12 +291,42 @@ Testing: Variable | Purpose -------- | ------- -GRIST_TESTING_SOCKET | a socket used for out-of-channel communication during tests only. +GRIST_TESTING_SOCKET | a socket used for out-of-channel communication during tests only. GRIST_TEST_HTTPS_OFFSET | if set, adds https ports at the specified offset. This is useful in testing. -GRIST_TEST_SSL_CERT | if set, contains filename of SSL certificate. -GRIST_TEST_SSL_KEY | if set, contains filename of SSL private key. -GRIST_TEST_LOGIN | allow fake unauthenticated test logins (suitable for dev environment only). -GRIST_TEST_ROUTER | if set, then the home server will serve a mock version of router api at /test/router +GRIST_TEST_SSL_CERT | if set, contains filename of SSL certificate. +GRIST_TEST_SSL_KEY | if set, contains filename of SSL private key. +GRIST_TEST_LOGIN | allow fake unauthenticated test logins (suitable for dev environment only). +GRIST_TEST_ROUTER | if set, then the home server will serve a mock version of router api at /test/router +GREP_TESTS | pattern for selecting specific tests to run (e.g. `env GREP_TESTS=ActionLog yarn test`). + +## Tests + +Tests are run automatically as part of CI when a PR is opened. However, it can be helpful to run tests locally +before pushing your changes to GitHub. First, you'll want to make sure you've installed all dependencies: + +``` +yarn install +yarn install:python +``` + +Then, you can run the main test suite like so: + +``` +yarn test +``` + +Python tests may also be run locally. (Note: currently requires Python 3.9.) + +``` +yarn test:python +``` + +For running specific tests, you can specify a pattern with the `GREP_TESTS` variable: + +``` +env GREP_TESTS=ChoiceList yarn test +env GREP_TESTS=summary yarn test:python +``` ## License diff --git a/package.json b/package.json index b7b1dd20..49fdcea8 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "test:server": "GRIST_SESSION_COOKIE=grist_test_cookie NODE_PATH=_build:_build/stubs:_build/ext mocha _build/test/server/**/*.js _build/test/gen-server/**/*.js", "test:smoke": "NODE_PATH=_build:_build/stubs:_build/ext mocha _build/test/nbrowser/Smoke.js", "test:docker": "./test/test_under_docker.sh", + "test:python": "sandbox_venv3/bin/python sandbox/grist/runtests.py ${GREP_TESTS:+discover -p \"test*${GREP_TESTS}*.py\"}", "cli": "NODE_PATH=_build:_build/stubs:_build/ext node _build/app/server/companion.js" }, "keywords": [