describedefines the name of the subject that you want to test. Its value can be any string that is relevant to your exercise. You can have multiple
describecalls in your evaluation if you need to test different subjects.
describe, you can define as many tests as you want that are related to that same subject, by calling the
itfunction. The string argument that
itreceives describes how the subject is expected to behave.
describeyou have access to the entire context of the student HTML document. You can:
window, just like the student can.
itto give a meaningful description of the test. In the above example, if any of the tests fail, this is what the student will see:
expectfunction is what actually decides whether a test fails or succeeds. Once you have a reference to a piece of the DOM (or other value) generated by student's code, you can assert whether it behaves as it should by calling:
toEqual()is called a Jasmine "matcher" and there are many more that you can use, like:
notif you want a negative assertion.
expectcalls fail inside a test, that test will be marked as failed by Jasmine and reported back to the student. If you want to give the student more granular feedback about a failing assertion, in your own words, you can pass an additional string argument to the matcher.
consoleOutput.loggedMessages, which is an array of strings: each string represents a call to
console.logfrom the user code.
foo()that is expected to return
true, and another one with a function
bar()that is expected to return
babeland add any necessary ES6 polyfills before serving them to PhantomJS.