-
Notifications
You must be signed in to change notification settings - Fork 88
Testing WaterBear
Why do we test?
We test so we can find bugs before they are released in to production. It tells us if what we intended to happen, actually happens. For a project that tries to tackle as much as WaterBear does it is important that the developers get the code base right. If we do not we may be teaching viewers how to code badly or turn them away from programming, which is the opposite of what we want. There are many more reasons for testing, but this is a short version. Happy Testing!
In order to test Waterbear one must first install node and then install all of the dependencies with node:
npm install
once all of the dev dependency packages are installed you should continue to the next section.
WaterBear uses mocha as a testing framework. Mocha is simple and easy to use. Mocha is a javascript test framework that can be used for synchronous and asynchronous testing. All mocha test cases are run serially and in conjunction with Mocha we use assertion libraries like chai and sinon for stubs and spies.
A small mocha example using chai would be:
describe("File Test Suite", function(){
it("Create File", function(){
// some code to attempt and test file creation
});
it("Delete File", function() {
// some code to attempt test file deletion.
});
});
###Small Tips
- If you find that *_runtime.js depends on a value generated at runtime, from the window object, another file create stubs for that needed value.
- Only load browsers that you can use
- You can run the mocha tests without using Karma with mocha testfile.js