layout | title | permalink |
---|---|---|
docs |
t.expect.typeOf Method |
/documentation/reference/test-api/testcontroller/expect/typeof.html |
Asserts that the actual
type is typeName
.
await t.expect( actual ).typeOf( typeName, message, options );
Parameter | Type | Description |
---|---|---|
actual |
Any type | A comparison value. See actual parameter value. |
typeName |
String | The expected type of an actual value. |
message (optional) |
String | An assertion message displayed in the report if the test fails. |
options (optional) |
Object | See Options. |
Examples:
await t
.expect({ a: 'bar' }).typeOf('object', 'it\'s an object')
.expect(/bar/).typeOf('regexp', 'it\'s a regular expression')
.expect(null).typeOf('null', 'it\'s a null');
import { Selector } from 'testcafe';
fixture `My fixture`;
test('My test', async t => {
await t.expect(Selector('#element').getAttribute('attr')).typeOf('string');
});
{% include assertions/actual-parameter-value.md %}
{% include assertions/timeout.md %}
{% include assertions/allowunawaitedpromise.md %}