Skip to content

ngMidwayTester.visit never executes callback #9

@pbtura

Description

@pbtura

I tried following the example from the docks and everything looked fine initially. When I dug a little deeper though I noticed a problem. The 'passing' test is actually a false negative. The callback function supplied as the second argument of the call to 'tester.visit' never actually executes, thus none of the assertions are actually tested.

Not sure if the problem is something in my setup or if it is a bug. Here is my spec, the only change I made was adding some logging:

angular.module('myModule', ['ngRoute'])
    .config(function($routeProvider) {
        $routeProvider.when('/home', {
            template : 'welcome to {{ title }}',
            controller : 'HomeCtrl'
        });
    })
    .controller('HomeCtrl', function($scope) {
        $scope.title = 'my home page foo';
    });

//this test spec uses mocha since it has nice support for async testing...
describe('my test spec', function() {
    var tester;
    beforeEach(function() {
        tester = ngMidwayTester('myModule', {
            template : '<div>' +
                '  <h1>hello</h1>' +
                '  <div id="view-container">' +
                '    <div ng-view></div>' +
                '  </div>' +
                '</div>'
        });
    });

    afterEach(function() {
        tester.destroy();
        tester = null;
    });

    it('should have a working home page', function(done) {

        console.log(['running home test']);
        tester.visit('/home', function() {
            console.log(['visited home']);
            expect("abc").toBe("xyz");
            expect(tester.path()).to.equal('/home');
            expect(tester.viewElement().html()).to.contain('welcome to my home page');

            var scope = tester.viewScope();
            expect(scope.title).to.equal('my home page');
            done();
        });

    });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions