mojotech / pioneer

Integration Testing
MIT License
527 stars 35 forks source link

Better errors details #296

Open bitplanets opened 9 years ago

bitplanets commented 9 years ago

I just got

C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1643
      throw error;
            ^
AssertionError: expected false to be true

What is going on? I don't even know what failed... Not even the line... nothing.

samccone commented 9 years ago

Without looking at your code it is hard to help with this error.

bitplanets commented 9 years ago

The problem was very easy to solve because I just had a test. This is not the question.

The issue is why the lib doesn't show the file and the line where the error happened?

bitplanets commented 9 years ago

Now I get this:

C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1643
      throw error;
            ^
Error: Wait timed out after 626ms
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1311:29
    at Object.webdriver.promise.asap (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:671:5)
    at newFrame.then.e (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1555:25)
    at C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\goog\base.js:1243:15
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1539:20)
    at notify (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:362:12)
    at notifyAll (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:331:7)
    at resolve (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:309:7)
    at fulfill (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:429:5)
    at webdriver.promise.ControlFlow.resolveFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1460:9)
    at webdriver.promise.ControlFlow.getNextTask_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1429:12)
    at webdriver.promise.ControlFlow.runEventLoop_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1387:59)
    at wrapper [as _onTimeout] (timers.js:261:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)
==== async task ====
    at webdriver.promise.ControlFlow.wait (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1296:15)
    at webdriver.WebDriver.wait (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:543:21)
    at Object.<anonymous> (C:\t\tests\steps\init.js:46:21)
    at C:\t\node_modules\pioneer\lib\support\index.js:65:25
    at webdriver.promise.ControlFlow.runInNewFrame_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1539:20)
    at webdriver.promise.ControlFlow.runEventLoop_ (C:\t\node_modules\pioneer\node_modules\selenium-webdriver\lib\webdriver\promise.js:1404:8)
    at wrapper [as _onTimeout] (timers.js:261:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

And the error should be here somewhere:

module.exports = function(){
    this.Given(/^I drop the database$/,function(){
        var databaseName    = 'test';
        var mongoose        = require('mongoose');
        var mongooseConnect = require('mongoose-connect');
        var connectData     = mongooseConnect.connect(databaseName, [], mongoose);
        var dropped         = false;
        connectData.connection.on('connected', function(){
            connectData.connection.db.dropDatabase(function(err, _dropped){
                (err === null).should.be.true;
                _dropped.should.be.true;
                dropped = true;
            });
        });
        this.driver.wait(function(){
            return dropped;
        }, 10 * 1000).then(function(){
        })
    });

    this.Given(/^I open the game$/,function(){
        this.driver.get('https://localhost/')
    });

    this.Given(/^I wait for (\d+) seconds$/,function(n){
        var timerDone = false;
        setTimeout(function(){
            timerDone = true;
        }, n * 1000)
        this.driver.wait(function(){
            return timerDone;
        }, Infinity).then(function(){
        })
    });

    this.When(/^I should see the loading screen$/, function(){
        this.Widget.isVisible({
            selector: '#preloader'
        }).then(function(value){
            value.should.be.true;
        })
    });

    this.Given(/^I wait for app to initialize (\d+) seconds$/,function(n){
        var inited = false;
        this.driver.wait(function(){
            var result = this.driver.executeScript('return data.init');
            result.then(function(value){
                if(inited) return;
                inited = value;
            })
        }.bind(this), n * 10).then(function(){
        })
    });

    this.When(/^I should have some planets$/, function(){
        var result = this.driver.executeScript('return data.stores.blockStore.getPlanets().length');
        result.then(function(value){
            parseInt(value).should.be.above(0);
        })
    });

    this.Then(/^I should see \"([^\"]*)\"$/, function(expected){
        var List = this.Widget.List.extend({
            root: "#todo-list",
            childSelector: "li"
        })

        return new List().readAt(0).should.eventually.eql(expected);
    })
}

How do you debug your tests? This is insane without a file and a line number. Well the error was that the wait method timed out.