-
Notifications
You must be signed in to change notification settings - Fork 1
Testing
This page is intended to introduce future developers to the format that current B-RIS developers used to create test suites, test the test suites, and test the actual site. Testing is crucial to ensure every part of B-RIS run effectively and efficiently, as such all tests need to pass with 100% certainty before able make a pull request and finally merge. Jest along with Node.js is used as the testing framework for B-RIS.
Test files can be identified by ".test.js" (Example: inverse.test.js). There are test suites for each rule in use, 13 in total. Test cases uses toBeTruthy and toBeFalsy to assert the equivalence of statement1 and statement2 under the chosen rule. Below is an example of three test cases from the DoubleNegation Test Suite.
For these test suites, generally it is great to have 15-20 cases minimum. Think about different corner cases, difficult boolean algebra statements, and cases that will just simply be wrong! Sometimes, it is nice to use some help to think of different test cases :)
To run tests the BRIS repository should have already been cloned (click for here the guide on how to clone). Once everything is set up and installed correctly, install the most current versions of npm and node.js in your terminal. Steps to install npm and node.js can be found here. Whether you are working on test suites or working on something related to appearance of the site, there are different ways to test.
When you are finished adding to the test suites, or simply just want to make sure that the test suites are working, open a terminal and enter the prompt:
npm run test
When npm is finished running the tests, there are two options that will show; either all of the test cases working and everything passed or something happened and the test suites do not pass. Here are two visuals!
When you are developing code for BRIS that does have to deal with the test suites, for example editing the appearance of the website, you would enter this into your terminal:
npm run start
This will start running, and if everything runs smoothly a different version of the BRIS site will open. This is the link that will open, but you must have entered npm run start
before anything will appear. From there you should be able to see everything that on the site and the changes that you implemented. The changes do not appear on the actual site, it is just showing you an instance of what is different. If there is an error that will cause the site to crash, npm run start will open up an error screen.