Coder Social home page Coder Social logo

Sychronize tests about frisby HOT 3 CLOSED

vlucas avatar vlucas commented on July 25, 2024
Sychronize tests

from frisby.

Comments (3)

cjsaylor avatar cjsaylor commented on July 25, 2024

@wino45 Check out the async library series control flow. I wouldn't recommend using it for all your tests as it would make it slow to execute, but if you want a situation without having to do a afterJSON callback each time, you could use that.

from frisby.

vlucas avatar vlucas commented on July 25, 2024

Yes - Try using another node.js flow control library to do this with your Frisby.js tests, as Frisby itself is not designed to be a synchronous library.

from frisby.

avishaan avatar avishaan commented on July 25, 2024

Using Async you could do something like this.

async.series([
function(cb){
    frisby
    .create('Get list of nerdys friends')
    .get(domain + '/users/' + user2.id + '/friends/page/1')
    .expectStatus(200)
    .afterJSON(function(user){
      //nerdy has no friends yet as he has not friended anyone
      expect(user.friends.length).toEqual(0);
      expect(user.friends).toBeDefined();
      cb(null);
    })
    .toss();
  },
  function(cb){
    frisby
    .create('Nerdy wants to be friends with popular, so make a friend request')
    .post(domain + '/users/' + user1.id + '/friendRequests', {
      friend: user2.id
    })
    .expectJSON(200)
    .after(function(){
      cb(null);
    })
    .toss();
  }
  ],
  function(err, results){
    callback(null);//call the next function in the test specs 
  });

from frisby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.