diff --git a/.gitignore b/.gitignore index 9f28e5cb447949081556e27b2b1702613de93bbc..2dcb4d9f42f23b7af576b707bd66f202bed1e826 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ __pycache__ *.db */env *.coverage +htmlcov .pytest_cache \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 72270e125a8b1eb2597597a576cd83192122ca04..326bf8345f9af184935d508ab4adbe3dd59cc890 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,7 +2,7 @@ "version": "2.0.0", "tasks": [ { - "label": "Client", + "label": "Start client", "type": "npm", "script": "start", "path": "client/", @@ -13,7 +13,26 @@ } }, { - "label": "Server", + "label": "Test client", + "type": "npm", + "script": "test:coverage:html", + "path": "client/", + "group": "test", + "problemMatcher": [], + }, + { + "label": "Open client coverage", + "type": "shell", + "group": "build", + "command": "start ./output/coverage/jest/index.html", + "problemMatcher": [], + "options": { + "cwd": "${workspaceFolder}/client" + }, + + }, + { + "label": "Start server", "type": "shell", "group": "build", "command": "env/Scripts/python main.py", @@ -26,10 +45,20 @@ } }, { - "label": "Test Server", + "label": "Test server", + "type": "shell", + "group": "build", + "command": "env/Scripts/pytest.exe --cov-report html --cov app tests/", + "problemMatcher": [], + "options": { + "cwd": "${workspaceFolder}/server" + }, + }, + { + "label": "Open server coverage", "type": "shell", "group": "build", - "command": "env/Scripts/pytest.exe --cov app tests/", + "command": "start ./htmlcov/index.html", "problemMatcher": [], "options": { "cwd": "${workspaceFolder}/server" @@ -37,7 +66,7 @@ }, { - "label": "Client + Server", + "label": "Start client and server", "group": "build", "dependsOn": [ "Server", diff --git a/README.md b/README.md index 66ebcfb30963378191d2d4aaea096f5af3efa910..96a4e7ebf172a1a1666ecb8979fd3a7886b82e13 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@   - # Scoring system for Teknikåttan This is the scoring system for Teknikåttan! @@ -13,6 +12,6 @@ To install the client and server needed to run the application, look in their re ## Using After installing both the client and the server, you are ready to run the application. -This is done in VSCode by pressing `ctrl+shift+b` and running the `Client + Server` task. +This is done in VSCode by pressing `ctrl+shift+b` and running the `Start client and server` task. The terminals for the client and server will now be seen on the right and left, respectively. -After making a change to either the client or the server while they are running, they will auto reload and you will see the changes immediately. +After making a change to either the client or the server while they are running, simply reload the page to see the changes immediately. diff --git a/client/.gitignore b/client/.gitignore index 4d29575de80483b005c29bfcac5061cd2f45313e..ef85236eb5861796d67cb5a15157d7e525e2989e 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -21,3 +21,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +output diff --git a/client/README.md b/client/README.md index da908d16ebb6009136be641e69e38cad9a7f0566..23cb20572c166b66b4e46f7ba58059ecab4fd66a 100644 --- a/client/README.md +++ b/client/README.md @@ -24,32 +24,33 @@ npm install ## Using After you have done every step described in setup, you are ready to start the client. -You can either start the client using tasks (recommended) or start it directly in the terminal. +To see the tasks described in the following steps, press `ctrl+shift+b`. -### Tasks +### Starting -You can run the client using Visual Studio Code tasks. -This is done by pressing `ctrl+shift+b` and running the `Client` task. +Start the server by running the `Start client` task. -### Terminal +### Testing + +Run the client tests running the `Test client` task. + +After it has finished, you can view a coverage report. +This is done by running the `Open client coverage` task. + +### Adding and removing new modules -You can also run the client directly from the terminal. All of the following snippets assume you are in the `client` folder. -Running the client: +Installing new module: ```bash -npm run start +npm install <module> ``` -Installing new modules: +Uninstalling module: ```bash -npm install new_module +npm uninstall <module> ``` Whenever a new module is installed, commited and pushed to git, everyone else needs to run `npm install` after pulling to install it as well. - -Author: Victor Löfgren - -Last updated: 11 February 2020 diff --git a/client/package.json b/client/package.json index 614f4d4c5b1fc0460a83234b61dd7020aa328191..a882fac0443fd3b7b6d4496adaae6343cabf4828 100644 --- a/client/package.json +++ b/client/package.json @@ -43,7 +43,8 @@ "test": "react-scripts test", "eject": "react-scripts eject", "lint": "eslint \"./src/**/*.{js,ts,tsx}\"", - "test:coverage": "react-scripts test --coverage --coverageDirectory=output/coverage/jest" + "test:coverage": "react-scripts test --coverage --coverageDirectory=output/coverage/jest", + "test:coverage:html": "npm test -- --coverage --watchAll=false --coverageDirectory=output/coverage/jest" }, "browserslist": { "production": [ @@ -65,7 +66,8 @@ ], "coverageReporters": [ "text", - "cobertura" + "cobertura", + "html" ] }, "proxy": "http://localhost:5000/api/" diff --git a/server/README.md b/server/README.md index b52b51c070844778fc4424670c8ab2ec6dc32a84..84d994d85e475930cd49d6a8adb0a6372289d302 100644 --- a/server/README.md +++ b/server/README.md @@ -11,7 +11,7 @@ You will need to do the following things to install the server: 3. Clone this repository if you haven't done so already. 4. Open the project folder in VSCode. 5. Open the integrated terminal by pressing `ctrl+ö`. -6. Type the following commands (or if you are on Windows, simply paste them) into your terminal: +6. Type the following commands into your terminal: ```bash # Install virtualenv package. You may need to open as administrator if you get @@ -29,12 +29,13 @@ py -m venv env # This step is different depending on your operating system. # Windows -# You migt to run the following before activating the virtual environment. Set-ExecutionPolicy Unrestricted -Scope Process ./env/Scripts/activate +# ===== # Linux/Mac -# source env/bin/activate +source env/bin/activate +# ===== # Install all the required packages into your virtual environment. pip install -r requirements.txt @@ -42,35 +43,40 @@ pip install -r requirements.txt ## Using -After you have done every step described in setup, you are ready to run the server. -You can either run the server using tasks (recommended) or run it directly in the terminal. +After you have done every step described in setup, you are ready to start the server. +To see the tasks described in the following steps, press `ctrl+shift+b`. -### Tasks +### Starting -You can run the server using Visual Studio Code tasks. -This is done by pressing `ctrl+shift+b` and running the `Server` task. +Start the server by running the `Start server` task. -### Terminal +### Testing -You can also run the server and tests directly from the terminal. -Before doing anything in the terminal, you need to activate the Python virtual environment (see Setup). -All of the following snippets assume you are in the `server` folder. +Run the client tests running the `Test server` task. -Running the server: +After it has finished, you can view a coverage report. +This is done by running the `Open server coverage` task. + +### Adding and removing new packages + +All of the following snippets assume you are in the `server` folder and have activated the virtual environment (see Setup). + +Installing new package: ```bash -python main.py +pip install <package> ``` -Running the tests: +Uninstalling package: ```bash -python test.py +pip uninstall <package> ``` -Adding new packages: +If you have added or removed a package from the repository, you will also have to run the following before commiting it to git: ```bash -pip install new_package pip freeze > requirements.txt ``` + +Whenever a new package is installed, commited and pushed to git, everyone else needs to run `pip install -r requirements.txt` after pulling to install it as well.