Running Assertions
Last updated
it('should have a JSON Content-Type header', function () {
return frisby.get('https://httpbin.org/headers')
.expect('header', 'Content-Type', 'application/json');
});it('should have a "Host" header with a value of "httpbin.org"', function () {
return frisby.get('https://httpbin.org/headers')
.expect('json', 'headers', {
Host: 'httpbin.org'
});
});it ('should return a list of feed items', function () {
return frisby
.get('https://jsonfeed.org/feed.json')
.expect('status', 200)
.expect('json', 'version', 'https://jsonfeed.org/version/1')
.expect('json', 'title', 'JSON Feed')
.expect('jsonTypes', 'items.*', { // Assert *each* object in 'items' array
'id': Joi.string().required(),
'url': Joi.string().uri().required(),
'title': Joi.string().required(),
'date_published': Joi.date().iso().required(),
});
});it('should return all headers as strings', function () {
return frisby.get('https://httpbin.org/headers')
// Using a wildcard in the path '*' check EACH value
.expect('jsonTypes', 'headers.*', frisby.Joi.string());
});it('should not return an error', function () {
return frisby.get('https://httpbin.org/headers')
// Should not return an error
.expectNot('json', { result: 'error' });
});