Skip to content

Commit

Permalink
fix tests on travis by stubbing renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Mar 28, 2017
1 parent aae63ff commit 5107326
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
35 changes: 35 additions & 0 deletions tests/browser/__init.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* __init.test.js is run before every test case.
*/
window.debug = true;
const AScene = require('aframe').AScene;

navigator.getVRDisplays = function () {
var resolvePromise = Promise.resolve();
var mockVRDisplay = {
requestPresent: resolvePromise,
exitPresent: resolvePromise,
getPose: function () { return { orientation: null, position: null }; },
requestAnimationFrame: function () { return 1; }
};
return Promise.resolve([mockVRDisplay]);
};

setup(function () {
this.sinon = sinon.sandbox.create();
// Stubs to not create a WebGL context since Travis CI runs headless.
this.sinon.stub(AScene.prototype, 'render');
this.sinon.stub(AScene.prototype, 'resize');
this.sinon.stub(AScene.prototype, 'setupRenderer');
});

teardown(function () {
// Clean up any attached elements.
var attachedEls = ['a-scene'];
var els = document.querySelectorAll(attachedEls.join(','));
for (var i = 0; i < els.length; i++) {
els[i].parentNode.removeChild(els[i]);
}
this.sinon.restore();
delete AFRAME.components.test;
});
6 changes: 0 additions & 6 deletions tests/browser/index.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import 'aframe';
import React from 'react';
import ReactDOM from 'react-dom';
import {Entity, Scene} from '../../src/index.js';

const div = document.createElement('div');
document.body.appendChild(div);

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

teardown(function () {
while (div.firstChild) { div.removeChild(div.firstChild); }
this.sinon.restore();
});

suite('aframe-react', () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/browser/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = function (config) {
],
frameworks: ['mocha', 'sinon-chai', 'chai-shallow-deep-equal'],
preprocessors: {
'src/**/*.js': ['webpack'],
'browser/**/*.js': ['webpack']
'src/**/*.js': ['webpack', 'sourcemap'],
'browser/**/*.js': ['webpack', 'sourcemap']
},
reporters: ['mocha'],
webpack: {
Expand Down

0 comments on commit 5107326

Please sign in to comment.