suiteJS.assertMatches(/234/, "12345")
var suite = suiteJS.createSuite("Optional Suite Name")
suite.testBar = function() {
this.assert("All methods named 'testSomething' will be run as tests when you run this suite.")
}
suite.run()
var suite = suiteJS.createSuite("Optional Suite Name")
suite.assert("This is pretty much the same as running a test with only this assertion.")
Fail right now. Any failure, be it by this function or by a failed assertion, will cause a test method to stop running in a test suite. This is because if you had one failure, the rest of the test is probably bogus, so it is not useful to continue. Other tests in the suite will still run. A failure that is not in a test method will not cause your program to stop running, though.
Set the function that is called on a pass. The passed function takes 1 argument, the pass message, and doesn’t need to return anything. Works for both the suiteJS object and individual suites.
suiteJS.setPass(function(msg) {
log.info("Test passed: " + msg)
}
See setPass(func)
Get number of passed assertions if called on suiteJS.
Get number of passed tests if called on a suite.
See getPassCount()
Reset pass and fail counts.
Get a string in the form “Passed 4 out of 10”
Returns true if last assertion passed, else false. Useful when chaining.
var dogIsRover = suiteJS.assert(dog).assertMatches(/[Rr]over/, dog.getName()).ok()
if (dogIsRover)
suiteJS.assert(dog.respondTo("Rover"))
Create a test suite. The name is optional: If not provided, a generic name will be used.
If it exists, this is called before every test in this suite.
var suite = suiteJS.createSuite()
suite.setUp = function() {
this.testData = new ModelObject()
}
See setUp. Same thing, but called after every test in the suite.
Note that the “msg” (short for “message”) argument is always optional.
Basically if (obj) pass.
Make sure the string is matched by the given regex.
Same as ==
Same as !=
Same as ===. If you’re not familiar with that, it means “This is the same object as that object” or, for primatives such as strings and numbers, “This is the same type and value as that object”
Checks if objects have same type based on result of typeof operator. In JavaScript, these are the only possible types:
Don’t get confused and think this will differentiate objects that were created different ways.
Pass if and only if the argument is null.
Pass if and only if the argument is not null.
Pass if and only if the argument is defined. Note that null is defined.
Pass if and only if the argument is undefined.
Pass if and only if the argument is true. Note that this is not the same as if (obj) pass. This only passes if you provide the actual true object. If you want the other behavior, use plain-old assert(obj, msg)
See assertTrue(obj, msg)