You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
});
});
});
The text was updated successfully, but these errors were encountered:
After some additional hair pulling, I figured out the issue. The visit call is asynchronous and requires mocha to work correctly. Mabey it would be a good idea to make the comment a little more clear. An example of how to do the same thing with jasmine might be good as well.
Unfortunately, I don't think I am using midway tester anymore so I don't have an example. I seem to recall that I need to use mocha rather than jasmine as a dependency (probably why I moved away from this solution). To be honest, this project is pretty old and there have been some significant changes to angular and karma since it was last updated. Even if I had an example of what I did, it probably would not work anymore.
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:
The text was updated successfully, but these errors were encountered: