RegExp asserter.
Assert that actual value is an instance of RegExp (using .isRegExp() assertion).
The regexp() asserter provides adapted assertions for works on an instance of RegExp.
See also the spec of "regexp" asserter for more examples.
Example
test.regexp(actual);
Methods
-
is(expected)
-
Assert
actualRegExpequality by content and if possible, recursively.Also handles circular and self-referential objects.
For most parts it asserts strict equality (
===), but:RegExpobjects are compared by their pattern and flags.
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 regexp = new RegExp(/[a-z]/); test.regexp(regexp).is(new RegExp(/[a-z]/));
See also -
isNot(expected)
-
Assert
actualRegExpto the negative equality by content and if possible, recursively.Also handles circular and self-referential objects.
For most parts it asserts strict (
!==), but:RegExpobjects are compared by their pattern and flags.
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 regexp = new RegExp(/[a-z]/); test.regexp(regexp).isNot(new RegExp(/[A-Z]/));
See also -
isIdenticalTo(expected)
-
Assert that the
actualRegExpis identical to (===)expectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/), ref = regexp ; test.regexp(regexp).isIdenticalTo(ref);
See also -
isNotIdenticalTo(expected)
-
Assert that the
actualRegExpis not identical to (!==)expectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/); test.regexp(regexp).isNotIdenticalTo(new RegExp(/[a-z]/));
See also -
isEqualTo(expected)
-
Assert that the
actualRegExpis equal to (==) theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/), ref = regexp ; test.regexp(regexp).isEqualTo(ref);
See also -
isNotEqualTo(expected)
-
Assert that the
actualRegExpis not equal to (!=) theexpectedvalue.ParametersName Type Description expected mixedExpected value
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/); test.regexp(regexp).isNotEqualTo(new RegExp(/[a-z]/));
See also -
match(expected)
-
Assert
actualRegExpto match theexpectedvalue.ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/), ref = regexp ; test.regexp(regexp).match(function(reg){ return reg === ref; });
See also -
notMatch(expected)
-
Assert
actualRegExpto not match theexpectedvalue.ParametersName Type Description expected StringNumberRegExpfunctionExpected value that must not match
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/), ref = regexp ; test.regexp(regexp).notMatch(function(actual){ var reg = new RegExp(/[a-z]/); return reg === ref || reg === actual; });
See also -
isValid(expected)
-
Alias of
match().ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/), ref = regexp ; test.regexp(regexp).isValid(function(reg){ return reg === ref; });
See also -
isNotValid(expected)
-
Alias of
notMatch().ParametersName Type Description expected StringNumberRegExpfunctionExpected matches
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/), ref = regexp ; test.regexp(regexp).isNotValid(function(actual){ var reg = new RegExp(/[a-z]/); return reg === ref || reg === actual; });
See also -
isEnumerable(property)
-
Assert that the
actualRegExphas an enumerableproperty. It will fail if theactualvalue lacks thepropertyentirely.This also checks inherited properties in the prototype chain, something which
Object.prototype.propertyIsEnumerableitself does not do.For checking if a property exists and is non-enumerable, see
isNotEnumerable().ParametersName Type Description property StringThe property name
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/); // define an enumerable property Object.defineProperty(regexp, 'myCustom', { enumerable: true, value: 'static' }); test.regexp(regexp).isEnumerable('myCustom');
See also -
isNotEnumerable(property)
-
Assert that the
actualRegExphas a non-enumerableproperty. It will fail if theactualvalue lacks thepropertyentirely.This also checks inherited properties in the prototype chain, something which
Object.prototype.propertyIsEnumerableitself does not do.It's the inverse of
isEnumerable().ParametersName Type Description property StringThe property name
ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/); // define a non-enumerable property Object.defineProperty(regexp, 'myCustom', { enumerable: false, value: 'static' }); test .regexp(regexp) .isNotEnumerable('myCustom') .isNotEnumerable('lastIndex') .isNotEnumerable('ignoreCase') .isNotEnumerable('multiline') ;
See also -
isFrozen()
-
Assert that the
actualRegExpis frozen withObject.isFrozen.ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/); Object.freeze(regexp); test.regexp(regexp).isFrozen();
See also -
isNotFrozen()
-
Assert that the
actualRegExpis not frozen withObject.isFrozen.ExampleReturnsType Description ObjectThe current instance
var regexp = new RegExp(/[a-z]/); test.regexp(regexp).isNotFrozen();
See also -
hasProperty(property, value)
-
Assert that the
actualtestedRegExphasproperty. Optionally assert it equals(===)tovalueargument.Takes inherited properties into account. To not do so, see
hasOwnProperty().ParametersName Type Argument Description property StringThe property name
value mixedoptional The property value
ExampleReturnsType Description ObjectThe current instance
test.regexp(/[a-z]/) .hasProperty('lastIndex') .hasProperty('constructor') ;
See also -
hasNotProperty(property, value)
-
Assert that the
actualtestedRegExphas not aproperty. Optionally assert it not equals(!==)tovalueargument.Takes inherited properties into account. To not do so, see
hasNotOwnProperty().ParametersName Type Argument Description property StringThe property name
value mixedoptional The property value
ExampleReturnsType Description ObjectThe current instance
test.regexp(/[a-z]/).hasNotProperty('foobar');
See also -
hasOwnProperty(property, value)
-
Assert that the
actualtestedRegExphas ownproperty. Optionally assert it equals(===)tovalueargument.Does not take inherited properties into account. To do so, see
hasProperty().ParametersName Type Argument Description property StringThe property name
value mixedoptional The property value
ExampleReturnsType Description ObjectThe current instance
test.regexp(/[a-z]/) .hasOwnProperty('lastIndex');
See also -
hasNotOwnProperty(property, value)
-
Assert that the
actualtestedRegExphas not ownproperty. Optionally assert it not equals(!==)tovalueargument.Does not take inherited properties into account. To do so, see
hasNotProperty().ParametersName Type Argument Description property StringThe property name
value mixedoptional The property value
ExampleReturnsType Description ObjectThe current instance
test.regexp(/[a-z]/) .hasNotOwnProperty('constructor');
See also -
hasKey(key, value)
-
Alias of hasProperty()Assert that the
actualtestedRegExphas akey. Optionally assert it equals(===)tovalueargument.Takes inherited properties into account. To not do so, see
hasOwnProperty().ParametersName Type Argument Description key StringThe key name
value mixedoptional The key value
ExampleReturnsType Description ObjectThe current instance
test.regexp(/[a-z]/) .hasKey('lastIndex') .hasKey('constructor') ;
See also -
notHasKey(key, value)
-
Alias of hasNotProperty()Assert that the
actualtestedRegExphas not akey. Optionally assert it not equals(!==)tovalueargument.Takes inherited properties into account. To not do so, see
hasNotOwnProperty().ParametersName Type Argument Description key StringThe key name
value mixedoptional The key value
ExampleReturnsType Description ObjectThe current instance
test.regexp(/[a-z]/).notHasKey('foobar');
See also