Skip to content

Commit b6336e0

Browse files
committed
Make sure a WebGL context is not initialized when running tests. Travis CI runs headless
1 parent 257a113 commit b6336e0

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

‎tests/__init.test.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ navigator.getVRDisplays = function () {
2121

2222
require('index');
2323
var AScene = require('core/scene/a-scene').AScene;
24+
// Make sure WebGL context is not created since Travix CT runs headless.
25+
// Stubs below failed once in a while due to asynchronous tesst setup / teardown.
26+
AScene.prototype.setupRenderer = function () {};
2427

2528
setup(function () {
2629
this.sinon = sinon.sandbox.create();

‎tests/core/component.test.js‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,12 @@ suite('Component', function () {
578578

579579
suite('third-party components', function () {
580580
var el;
581-
setup(function () {
581+
setup(function (done) {
582582
el = entityFactory();
583583
delete components.clone;
584+
el.addEventListener('loaded', () => {
585+
done();
586+
});
584587
});
585588

586589
test('can be registered', function () {
@@ -589,17 +592,13 @@ suite('Component', function () {
589592
assert.ok('clone' in components);
590593
});
591594

592-
test('can change behavior of entity', function (done) {
595+
test('can change behavior of entity', function () {
593596
registerComponent('clone', CloneComponent);
594-
595-
el.addEventListener('loaded', function () {
596-
assert.notOk('clone' in el.components);
597-
assert.notOk(el.object3D.children.length);
598-
el.setAttribute('clone', '');
599-
assert.ok('clone' in el.components);
600-
assert.equal(el.object3D.children[0].uuid, 'Bubble Fett');
601-
done();
602-
});
597+
assert.notOk('clone' in el.components);
598+
assert.notOk(el.object3D.children.length);
599+
el.setAttribute('clone', '');
600+
assert.ok('clone' in el.components);
601+
assert.equal(el.object3D.children[0].uuid, 'Bubble Fett');
603602
});
604603

605604
test('cannot be registered if it uses the character __ in the name', function () {

0 commit comments

Comments
 (0)