* address FIXME regarding jasmine.done()

* support disabling tests / reporting as pending
This commit is contained in:
humbletim 2017-02-23 09:09:54 -05:00
parent 1564c76ab4
commit 24dd06b65e
4 changed files with 46 additions and 6 deletions

View file

@ -6,7 +6,7 @@
var lastSpecStartTime;
function ConsoleReporter(options) {
var startTime = new Date().getTime();
var errorCount = 0;
var errorCount = 0, pending = [];
this.jasmineStarted = function (obj) {
print('Jasmine started with ' + obj.totalSpecsDefined + ' tests.');
};
@ -15,11 +15,15 @@
var endTime = new Date().getTime();
print('<hr />');
if (errorCount === 0) {
print ('<span style="color:green">All tests passed!</span>');
print ('<span style="color:green">All enabled tests passed!</span>');
} else {
print('<span style="color:red">Tests completed with ' +
errorCount + ' ' + ERROR + '.<span>');
}
if (pending.length) {
print ('<span style="color:darkorange">disabled: <br />&nbsp;&nbsp;&nbsp;'+
pending.join('<br />&nbsp;&nbsp;&nbsp;')+'</span>');
}
print('Tests completed in ' + (endTime - startTime) + 'ms.');
};
this.suiteStarted = function(obj) {
@ -32,6 +36,10 @@
lastSpecStartTime = new Date().getTime();
};
this.specDone = function(obj) {
if (obj.status === 'pending') {
pending.push(obj.fullName);
return print('...(pending ' + obj.fullName +')');
}
var specEndTime = new Date().getTime();
var symbol = obj.status === PASSED ?
'<span style="color:green">' + CHECKMARK + '</span>' :

View file

@ -8,6 +8,15 @@ var ROT_IDENT = {x: 0, y: 0, z: 0, w: 1};
describe("MyAvatar", function () {
// backup/restore current skeletonModelURL
beforeAll(function() {
this.oldURL = MyAvatar.skeletonModelURL;
});
afterAll(function() {
MyAvatar.skeletonModelURL = this.oldURL;
});
// reload the avatar from scratch before each test.
beforeEach(function (done) {
MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL;
@ -25,7 +34,7 @@ describe("MyAvatar", function () {
}, 500);
}
}, 500);
});
}, 10000 /*timeout -- allow time to download avatar*/);
// makes the assumption that there is solid ground somewhat underneath the avatar.
it("position and orientation getters", function () {

View file

@ -19,6 +19,14 @@ describe('Entity', function() {
},
};
it('serversExist', function() {
expect(Entities.serversExist()).toBe(true);
});
it('canRezTmp', function() {
expect(Entities.canRezTmp()).toBe(true);
});
beforeEach(function() {
boxEntity = Entities.addEntity(boxProps);
});

View file

@ -3,11 +3,26 @@ Script.include('../../libraries/jasmine/jasmine.js');
Script.include('../../libraries/jasmine/hifi-boot.js')
// Include unit tests
// FIXME: Figure out why jasmine done() is not working.
// Script.include('avatarUnitTests.js');
Script.include('avatarUnitTests.js');
Script.include('bindUnitTest.js');
Script.include('entityUnitTests.js');
describe("jasmine internal tests", function() {
it('should support async .done()', function(done) {
var start = new Date;
Script.setTimeout(function() {
expect((new Date - start)/1000).toBeCloseTo(0.5, 1);
done();
}, 500);
});
// jasmine pending test
xit('disabled test', function() {
expect(false).toBe(true);
});
});
// invoke Script.stop (after any async tests complete)
jasmine.getEnv().addReporter({ jasmineDone: Script.stop });
// Run the tests
jasmine.getEnv().execute();
Script.stop();