Skip to content

Backend tests

Roni Juntunen edited this page Dec 14, 2019 · 3 revisions

Backend tests

Backend has at the moment 20 unit tests that may be run using scripts in /dev_scripts folder.

Running tests

  1. Complete quick start instructions according to README.md
  2. Shutdown all docker containers that are started by quick start guide.
  3. Install application dependencies
    • Go to backend folder and run npm install
    • Go to frontend folder and run npm install
  4. Go to dev_scripts directory
  5. Run command ./start_dev
    • This should start database and frontend in development mode
  6. Run command ./test_backend
  7. Unit tests should be now completed

More information from dev_scripts directory may be found from Development scripts page

Editing unit tests

Unit tests can be find from /backend/test folder. There are four unit test files: tests.js, userTests.js, postTests.js and searchTests.js. tests.js contains some preliminary preparations for all tests and has order witch tests should be run. Other files have unit tests related to their own routers and controllers. Unit tests have been written with Mocha test framework and Chai assertion library. Familiarize your self with those libraries before editing tests.

Python scripts

Python scripts in the test folder are used for data generation. Those scripts generates 101 users and 100 posts. Generated data is used in unit tests. If more advanced data is needed for testing those scripts could be modified.

Clone this wiki locally