Date asserter.
Assert that the actual value is an instance of Date (using .isDate() assertion).
The date() asserter provides adapted assertions for works on a Date instance.
See also the spec of "date" asserter for more examples.
Example
test.date(actual);
Methods
-
is(expected)
-
Assert
actualDateequality by content and if possible, recursively.Also handles circular and self-referential objects.
For most parts it asserts strict equality (
===), but:Dateobjects are compared by their value.- Instances of the same class with a
valueOffunction are compared by its output. - Plain objects and instances of the same class are compared recursively.
Does not coerce types so mismatching types fail. Inherited enumerable properties are also taken into account.
ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(date).is(new Date('2010, 5, 20'));
See also -
isNot(expected)
-
Assert
actualDateto the negative equality by content and if possible, recursively.Also handles circular and self-referential objects.
For most parts it asserts strict (
!==), but:Dateobjects are compared by their value.- Instances of the same class with a
valueOffunction are compared by its output. - Plain objects and instances of the same class are compared recursively.
Does not coerce types so mismatching types fail. Inherited enumerable properties are also taken into account.
ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(date).isNot(new Date('2012, 02, 28'));
See also -
isIdenticalTo(expected)
-
Assert that the
actualDateis identical to (===)expecteddate.ParametersName Type Description expected mixedExpected date
ExampleReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); var ref = date; test.date(ref).isIdenticalTo(date);
See also -
isNotIdenticalTo(expected)
-
Assert that the
actualDateis not identical to (!==)expecteddate.ParametersName Type Description expected mixedExpected date
ExampleReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(date).isNotIdenticalTo(new Date('2010, 5, 20'));
See also -
isEqualTo(expected)
-
Assert that the
actualDateis equal to (==) theexpecteddate.ParametersName Type Description expected mixedExpected date
ExampleReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); var ref = date; test.date(ref).isEqualTo(date);
See also -
isNotEqualTo(expected)
-
Assert that the
actualDateis not equal to (!=) theexpecteddate.ParametersName Type Description expected mixedExpected date
ExampleReturnsType Description ObjectThe current instance
var date = new Date('2010, 5, 20'); test.date(new Date('2010, 5, 20')).isNotEqualTo(date);
See also -
match(expected)
-
Assert
actualDateto match theexpectedvalue.ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).match(/2010/);
See also -
notMatch(expected)
-
Assert
actualDateto not match theexpectedvalue.ParametersName Type Description expected StringNumberRegExpfunctionExpected value that must not match
ExampleReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).notMatch(/2012/);
See also -
isValid(expected)
-
Alias of
match().ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).isValid(/2010/);
See also -
isNotValid(expected)
-
Alias of
notMatch().ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')).isNotValid(/2012/);
See also -
isBetween(begin, end)
-
Assert that the
actualDateis betweenbeginandend(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ExampleReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')) .isBetween(new Date('1982, 02, 17'), new Date('2012, 02, 28'));
See also -
isNotBetween(begin, end)
-
Assert that the
actualDateis not betweenbeginandend(inclusive).ParametersName Type Description begin numberBegin value
end numberEnd value
ExampleReturnsType Description ObjectThe current instance
test.date(new Date('2010, 5, 20')) .isNotBetween(new Date('2011, 02, 17'), new Date('2012, 02, 28'));
See also -
isBefore(expected)
-
Assert that the
actualDateis before theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test.date(new Date(2010, 5, 20)).isBefore(new Date(2012, 2, 28));
See also -
isAfter(expected)
-
Assert that the
actualDateis after theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
test.date(new Date(2012, 2, 28)).isAfter(new Date(2010, 5, 20));
See also

