Skip to content

Testing

Diana Issatayeva edited this page May 14, 2021 · 2 revisions

Running the Tests

Tests are currently written in individual .spec.js or .test.js scripts located throughout the project (NOT only .js). These test scripts will be dynamically loaded when running the tester. We use jest as our test runner.

Similar to running the main program, after saving any changes, open a command line or terminal and enter into the project directory. Then execute:

npm test

This will find and load all written tests and compute them. Once complete, the tester will report test results, successes, and failures.

It is recommended to write only a single .spec.js file per “subject”. And within each file, divide each test case by a local block. This is to ensure local variables do not contaminate other tests. For example:

//Test empty
{
  console.log("Testing empty...");
  ...
  console.log("Finished testing empty.");
}

NOTE: If a test runs into any errors or failures, any outputs gathered during computation are outputted in the order they occur, therefore console.log should print in the order expected. If a test was successful, all test output is consumed and not printed.

FILES_SPEC

Spec files

Any scripts that ends with .spec.js will be processed by jest as a unit test. These are your basic unit tests which can test any JavaScript and also React components (as it is currently set up to do).

Clone this wiki locally