Skip to content

Commit

Permalink
add node compatibility and regression test (aframevr#2484)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Selden authored and ngokevin committed Mar 15, 2017
1 parent 56bb0b9 commit 226f1fd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ env:
matrix:
- CI_ACTION="npm run test:firefox -- --single-run"
- CI_ACTION="npm run test:chrome -- --single-run"
- CI_ACTION="npm run test:node"
- CI_ACTION="npm run lint"
- CI_ACTION="npm run build"
- CI_ACTION="npm run test:docs"
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"test": "karma start ./tests/karma.conf.js",
"test:docs": "node scripts/docsLint.js",
"test:firefox": "npm test -- --browsers Firefox",
"test:chrome": "npm test -- --browsers Chrome"
"test:chrome": "npm test -- --browsers Chrome",
"test:node": "mocha tests/node"
},
"repository": "aframevr/aframe",
"license": "MIT",
Expand Down Expand Up @@ -59,6 +60,7 @@
"glob": "^7.1.1",
"husky": "^0.11.7",
"istanbul": "^0.4.5",
"jsdom": "^9.11.0",
"karma": "^1.3.0",
"karma-browserify": "^5.1.0",
"karma-chai-shallow-deep-equal": "0.0.4",
Expand Down
55 changes: 55 additions & 0 deletions tests/node/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* eslint-env mocha */
'use strict';

const path = require('path');
const expect = require('chai').expect;
const jsdom = require('jsdom');
const Module = require('module');
const sinon = require('sinon');

const _require = Module.prototype.require;

describe('node acceptance tests', function () {
let sandbox;

before(function () {
sandbox = sinon.sandbox.create();
sandbox.stub(Module.prototype, 'require', function () {
if (arguments[0].indexOf('.css') === -1) {
return _require.apply(this, arguments);
}
});
});

beforeEach(function () {
let _window = global.window = jsdom.jsdom().defaultView;
global.navigator = _window.navigator;
global.document = _window.document;
global.HTMLElement = _window.HTMLElement;
Object.defineProperty(_window, 'WebVRConfig', {
get () {
return global.WebVRConfig;
},
set (WebVRConfig) {
global.WebVRConfig = WebVRConfig;
}
});
});

afterEach(function () {
delete global.window;
delete global.document;
delete global.HTMLElement;
delete global.WebVRConfig;
});

after(function () {
sandbox.restore();
});

it('can run in node', function () {
let aframe = require(path.join(process.cwd(), 'src'));

expect(aframe.version).to.be.ok;
});
});

0 comments on commit 226f1fd

Please sign in to comment.