const frisby = require('frisby');
const Joi = frisby.Joi; // Frisby exposes Joi for convenience
describe('Posts', function () {
it('should return all posts and first post should have comments', function () {
return frisby.get('http://jsonplaceholder.typicode.com/posts')
.expect('jsonTypes', '*', {
.then(function (res) { // res = FrisbyResponse object
let postId = res.json[0].id;
// Get first post's comments
// RETURN the FrisbySpec object so function waits on it to finish - just like a Promise chain
return frisby.get('http://jsonplaceholder.typicode.com/posts/' + postId + '/comments')
.expect('jsonTypes', '*', {
email: Joi.string().email(),