axemclion / browser-perf

Performance Metrics for Web Browsers
BSD 2-Clause "Simplified" License
936 stars 61 forks source link

TypeError: cb is not a function #74

Closed jahnavi310 closed 8 years ago

jahnavi310 commented 8 years ago

I am trying to use browser-perf to read the data using browser-perf:

this is what i have: i have all the urls stored in a file so before executing the following function:

 browserPerf(url, function(err, data) {
            console.log(url);
            if (err) {
                console.log('ERROR: ' + err);
             } else {
                console.log(data);
      }, {
            selenium: 'http://localhost:4444/wd/hub',
            browsers: ['chrome'] 
        });

, i am reading all of them one by one from the file

but the console.log(url) does not execute as expected because it seems like this returns a promise, it just times out, any idea how to resolve this issue?

This is what i have:

fs.readFile('urls.txt', 'UTF-8', function (err,urls) {
            if (err) {
                return console.log(err);
            }

            var urls = urls.split("\n");
            urls.shift();

            urls.forEach(function(url) {            
                console.log(url);
                self.getStats(url);
            });      

});

test: function(url) {
        new Promise(function(err,data) {
            console.log("URL: ", url);
        });
    },

    getStats: function(url) {
        var self = this;
        browserPerf(url, self.test(url), {
            selenium: 'http://localhost:4444/wd/hub',
            browsers: ['chrome'] 
        });
});

This is when i get that error

jahnavi310 commented 8 years ago

@axemclion: ^^

axemclion commented 8 years ago

@jahnavi310 self.test(url) here returns undefined. It should return a function, and could be like

test: function(url) {
       return function(err, res){
              console.log("URL: ", url);
       }
},