Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
The test suite leverages the Karma Test Runner. This is the thing that runs the tests in various browsers and environments. The actual tests themselves are written with Jasmine:
First, your JS/CSS files should be built (via
gulp dist or
Then you can run the tests from a browser (this will output a URL that you can visit):
Alternatively, you can run the tests headlessly:
# runs once... gulp test:single # OR, runs continuously, watching changes.. gulp test:headless
Both commands will watch for any changes made to source files or test files, and then automatically rereun the tests.
.jsfile per "thing" you are testing.
Write the tests. Look at other tests in the directory for inspiration on how a test file is laid out.
Make sure your tests pass. Run the
gulp testcommands mentioned above.
What to test for
We are mostly doing "black box testing", which means we don't care about testing the internals, mainly just the input and output. For most options, this will entail inspecting the DOM to see if the option had the desired effect. This might involve checking an element for certain text, a certain className, or a certain pixel width. An example of this can be seen with minTime.
To test API methods (like updateEvent), call the method with a healthy variety of arguments and make sure the desired output occurs, whether by querying DOM or querying the internal state of the calendar with a different method. Also, make sure all the proper callbacks have been called (if applicable).
When you are writing a new test, it is often annoying to have to run all tests every time while you are debugging. Jasmine allows you to write
fit statements, which will only run the enclosed tests and ignore all others.
Also, when running tests in a real browsers via the plain
gulp test command, it is very helpful to use Karma's "debug" mode (available via the big DEBUG button). Once you are in that mode, JS debugging tools such as console and breakpoints will become available.
The jasmine-jquery library is available to make it easier to query the DOM for certain things. It adds extra DOM-specific utility methods to the
The jasmine-fixture library is available to make it easier to create and attach DOM elements through the
affix method. They also automatically get cleaned up after each
it statement runs.
Code formatting of tests
Please make sure your test code follows the Style Guide and that you run
gulp check before committing.
If you have any questions on what to tests, or how to organize your tests, post a question on the Google Group.