diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5496ba8..492cf78d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,30 +6,50 @@ Please use [Prettier](https://prettier.io/) to format the code. ## Tests -As Typesaurus itself, its tests work both in browser and Node.js. Typesaurus tests connect to a real database, so to run them, you need to prepare a Firebase project and point the suite to the project. See [How to set up tests?](#how-to-set-up-tests) for more details. +### Unit tests -### How to run tests? +Before running unit tests for the first time, you need to download the Firestore emulator by running the command: + +```bash +make test-setup +``` To run the tests: ```bash -# Run tests both in Node.js and browser: +# Run tests once make test +# Run tests in the watch mode +make test-watch +``` + +### System tests + +As Typesaurus itself, its tests work both in browser and Node.js. Typesaurus system tests connect to a real database, so to run them, you need to prepare a Firebase project and point the suite to the project. See [How to set up tests?](#how-to-set-up-system-tests) for more details. + +#### How to run system tests? + +To run the tests: + +```bash +# Run tests both in Node.js and browser: +make test-system + # Run only Node.js tests: -make test-node +make test-system-node # Run Node.js tests in the watch mode: -make test-node-watch +make test-system-node-watch # Run only browser tests: -make test-node +make test-system-browser # Run browser tests in the watch mode: -make test-node-watch +make test-system-browser-watch ``` -### How to set up tests? +#### How to set up system tests? 1. First of all, [create a Firebase project](https://console.firebase.google.com/) and [enable Firestore](https://console.firebase.google.com/project/_/storage). diff --git a/Makefile b/Makefile index 1a7249ad..bc4a919d 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ test: test-watch: ${BIN}/firebase emulators:exec --only firestore "${BIN}/jest --env node --watch" +test-setup: + ${BIN}/firebase setup:emulators:firestore + test-system: test-system-node test-system-browser test-system-node: