Sometimes you have some HTTP calls that are dependent on others, like creating a new item and then checking to ensure that it exists and is returned from the API.
Here is a more complex test example with nested dependent Frisby tests with Frisby's Promise-style `then` method.
constfrisby=require('frisby');constJoi=frisby.Joi; // Frisby exposes Joi for conveniencedescribe('Posts',function () {it('should return all posts and first post should have comments',function () {returnfrisby.get('http://jsonplaceholder.typicode.com/posts').expect('status',200).expect('jsonTypes','*', { userId:Joi.number(), id:Joi.number(), title:Joi.string(), body:Joi.string() }).then(function (res) { // res = FrisbyResponse objectlet 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 chainreturnfrisby.get('http://jsonplaceholder.typicode.com/posts/'+ postId +'/comments').expect('status',200).expect('json','*', { postId: postId }).expect('jsonTypes','*', { postId:Joi.number(), id:Joi.number(), name:Joi.string(), email:Joi.string().email(), body:Joi.string() }); }); });});