Matchers
The toBe() matcher represents an equality matcher much how an $assert.isEqual() behaves. Below are several of the most common matchers available to you. However, the best way to see which ones are available is to checkout the API Docs.
1
toBeTrue( [message] ) : value to true
2
toBeFalse( [message] ) : value to be false
3
toBe( expected, [message] ) : Assert something is equal to each other, no case is required
4
toBeWithCase( expected, [message] ) : Expects with case
5
toBeNull( [message] ) : Expects the value to be null
6
toBeInstanceOf( class, [message] ) : To be the class instance passed
7
toMatch( regex, [message] ) : Matches a string with no case-sensitivity
8
toMatchWithCase( regex, [message] ) : Matches with case-sensitivity
9
toBeTypeOf( type, [message] ) : Assert the type of the incoming actual data, it uses the internal ColdFusion isValid() function behind the scenes, type can be array, binary, boolean, component, date, time, float, numeric, integer, query, string, struct, url, uuid plus all the ones from isValid()
10
toBe{type}( [message] ) : Same as above but more readable method name. Example: .toBeStruct(), .toBeArray()
11
toBeEmpty( [message] ) : Tests if an array or struct or string or query is empty
12
toHaveKey( key, [message] ) : Tests the existence of one key in a structure or hash map
13
toHaveDeepKey( key, [message] ) : Assert that a given key exists in the passed in struct by searching the entire nested structure
14
toHaveLength( length, [message] ) : Assert the size of a given string, array, structure or query
15
toThrow( [type], [regex], [message] );
16
toBeCloseTo( expected, delta, [datepart], [message] ) : Can be used to approximate numbers or dates according to the expected and delta arguments. For date ranges use the datepart values.
17
toBeBetween( min, max, [message] ) : Assert that the passed in actual number or date is between the passed in min and max values
18
toInclude( needle, [message] ) : Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity, needle in a haystack anyone?
19
toIncludeWithCase( needle, [message] ) : Assert that the given "needle" argument exists in the incoming string or array with case-sensitivity, needle in a haystack anyone?
20
toBeGT( target, [message] ) : Assert that the actual value is greater than the target value
21
toBeGTE( target, [message] ) : Assert that the actual value is greater than or equal the target value
22
toBeLT( target, [message] ) : Assert that the actual value is less than the target value
23
toBeLTE( target, [message] ) : Assert that the actual value is less than or equal the target value
Copied!
Copy link
Edit on GitHub