Skip to content

Commit 78a5577

Browse files
Update test stack (#5091)
* update karma mocha sinon chai * update jsdom * update glob and write-good used by test:docs script * remove non used lolex test dependency * update browserify-istanbul for karma coverage to work
1 parent a8dca3a commit 78a5577

File tree

11 files changed

+36
-36
lines changed

11 files changed

+36
-36
lines changed

docs/core/globals.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ global. This same interface is also exposed if requiring with CommonJS
5353

5454
## Requiring `AFRAME` in a Node.js Environment
5555

56-
It is possible to run A-Frame in [Node.js](https://nodejs.org/en/about) to get access to its globals. The only catch is we need to supply a browser `window` mock since Node.js lacks a `window` object. A-Frame is tested with [jsdom](https://github.com/tmpvar/jsdom), although any JavaScript-based browser implementation should work.
56+
It is possible to run A-Frame in [Node.js](https://nodejs.org/en/about) to get access to its globals. The only catch is we need to supply a browser `window` mock since Node.js lacks a `window` object. A-Frame is tested with [jsdom](https://github.com/jsdom/jsdom), although any JavaScript-based browser implementation should work.
5757

5858
```js
59-
global.window = require('jsdom').jsdom().defaultView;
59+
const jsdom = require("jsdom");
60+
global.window = new jsdom.JSDOM().window;
6061
var aframe = require('aframe/src');
6162
console.log(aframe.version);
6263
```

package.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
"browserify": "^13.1.0",
5656
"browserify-css": "^0.8.4",
5757
"browserify-derequire": "^0.9.4",
58-
"browserify-istanbul": "^2.0.0",
58+
"browserify-istanbul": "^3.0.1",
5959
"budo": "^9.2.0",
60-
"chai": "^3.5.0",
60+
"chai": "^4.3.6",
6161
"chai-shallow-deep-equal": "^1.4.0",
6262
"chalk": "^1.1.3",
6363
"codecov": "^1.0.1",
@@ -66,35 +66,34 @@
6666
"exorcist": "^0.4.0",
6767
"ghpages": "0.0.8",
6868
"git-rev": "^0.2.1",
69-
"glob": "^7.1.1",
69+
"glob": "^8.0.3",
7070
"husky": "^0.11.7",
7171
"istanbul": "^0.4.5",
72-
"jsdom": "^9.11.0",
73-
"karma": "1.4.1",
74-
"karma-browserify": "^5.1.0",
72+
"jsdom": "^20.0.0",
73+
"karma": "^6.4.0",
74+
"karma-browserify": "^8.1.0",
7575
"karma-chai-shallow-deep-equal": "0.0.4",
76-
"karma-chrome-launcher": "^2.0.0",
77-
"karma-coverage": "^1.1.1",
76+
"karma-chrome-launcher": "^3.1.1",
77+
"karma-coverage": "^2.2.0",
7878
"karma-env-preprocessor": "^0.1.1",
79-
"karma-firefox-launcher": "^1.2.0",
80-
"karma-mocha": "^1.1.1",
81-
"karma-mocha-reporter": "^2.1.0",
82-
"karma-sinon-chai": "1.2.4",
83-
"lolex": "^1.5.1",
79+
"karma-firefox-launcher": "^2.1.2",
80+
"karma-mocha": "^2.0.1",
81+
"karma-mocha-reporter": "^2.2.5",
82+
"karma-sinon-chai": "^2.0.2",
8483
"markserv": "github:sukima/markserv#feature/fix-broken-websoketio-link",
8584
"minifyify": "^7.3.3",
86-
"mocha": "^3.0.2",
85+
"mocha": "^10.0.0",
8786
"mozilla-download": "^1.1.1",
8887
"replace-in-file": "^2.5.3",
8988
"semistandard": "^9.0.0",
9089
"shelljs": "^0.7.7",
9190
"shx": "^0.2.2",
92-
"sinon": "^1.17.5",
93-
"sinon-chai": "2.8.0",
91+
"sinon": "<12.0.0",
92+
"sinon-chai": "^3.7.0",
9493
"snazzy": "^5.0.0",
9594
"too-wordy": "ngokevin/too-wordy",
9695
"uglifyjs": "^2.4.10",
97-
"write-good": "^0.9.1"
96+
"write-good": "^1.0.8"
9897
},
9998
"link": true,
10099
"browserify": {

tests/__init.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var AScene = require('core/scene/a-scene').AScene;
2626
AScene.prototype.setupRenderer = function () {};
2727

2828
setup(function () {
29-
this.sinon = sinon.sandbox.create();
29+
this.sinon = sinon.createSandbox();
3030
// Stubs to not create a WebGL context since Travis CI runs headless.
3131
this.sinon.stub(AScene.prototype, 'render');
3232
this.sinon.stub(AScene.prototype, 'setupRenderer');

tests/components/cursor.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ suite('cursor', function () {
237237
var nearerIntersectedEl = document.createElement('a-entity');
238238
var furtherIntersectedEl = document.createElement('a-entity');
239239

240-
this.sinon.stub(el.components.raycaster, 'getIntersection', function (el) {
240+
this.sinon.replace(el.components.raycaster, 'getIntersection', function (el) {
241241
switch (el) {
242242
case intersectedEl: return intersection1;
243243
case nearerIntersectedEl: return intersection2;
@@ -279,7 +279,7 @@ suite('cursor', function () {
279279
once(prevIntersectedEl, 'mouseleave', function (evt) {
280280
done();
281281
});
282-
this.sinon.stub(el.components.raycaster, 'getIntersection', function (el) {
282+
this.sinon.replace(el.components.raycaster, 'getIntersection', function (el) {
283283
return el === intersectedEl ? intersection : prevIntersection;
284284
});
285285
el.emit('raycaster-intersection', {

tests/components/gltf-model.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ suite('gltf-model', function () {
7171
animations: animations
7272
};
7373

74-
this.sinon.stub(THREE, 'GLTFLoader', function MockGLTFLoader () {
74+
this.sinon.replace(THREE, 'GLTFLoader', function MockGLTFLoader () {
7575
this.load = function (url, onLoad) {
7676
process.nextTick(onLoad.bind(null, gltfMock));
7777
};

tests/components/material.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ suite('material', function () {
1010

1111
setup(function (done) {
1212
el = entityFactory();
13-
this.sinon = sinon.sandbox.create();
13+
this.sinon = sinon.createSandbox();
1414
el.setAttribute('geometry', '');
1515
el.setAttribute('material', 'shader: flat');
1616
if (el.hasLoaded) { done(); }

tests/components/oculus-go-controls.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ suite('oculus-go-controls', function () {
101101
// Remove the controllers and verify that everything is cleaned up correctly. We do this
102102
// by resetting the spy methods so we are certain only the remove is called.
103103
controllerSystem.controllers = [];
104-
injectTrackedControlsSpy.reset();
105-
addEventListenersSpy.reset();
106-
removeEventListenersSpy.reset();
104+
injectTrackedControlsSpy.resetHistory();
105+
addEventListenersSpy.resetHistory();
106+
removeEventListenersSpy.resetHistory();
107107

108108
component.checkIfControllerPresent();
109109

tests/components/oculus-touch-controls.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ suite('oculus-touch-controls', function () {
9999
// Remove the controllers and verify that everything is cleaned up correctly. We do this
100100
// by resetting the spy methods so we are certain only the remove is called.
101101
controllerSystem.controllers = [];
102-
injectTrackedControlsSpy.reset();
103-
addEventListenersSpy.reset();
104-
removeEventListenersSpy.reset();
102+
injectTrackedControlsSpy.resetHistory();
103+
addEventListenersSpy.resetHistory();
104+
removeEventListenersSpy.resetHistory();
105105

106106
component.checkIfControllerPresent();
107107

tests/components/text.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ suite('text', function () {
77
var el;
88

99
setup(function (done) {
10-
this.sinon.stub(Component.prototype, 'lookupFont', function (key) {
10+
this.sinon.replace(Component.prototype, 'lookupFont', function (key) {
1111
return {
1212
default: '/base/tests/assets/test.fnt?foo',
1313
mozillavr: '/base/tests/assets/test.fnt?bar',

tests/core/a-entity.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ suite('a-entity', function () {
930930

931931
test('does not initialized non-registered component', function () {
932932
var nativeSetAttribute = HTMLElement.prototype.setAttribute;
933-
this.sinon.stub(el, 'setAttribute', nativeSetAttribute);
933+
this.sinon.replace(el, 'setAttribute', nativeSetAttribute);
934934
el.setAttribute('fake-component', 'color: #F0F;');
935935
el.initComponent('fake-component');
936936
assert.notOk(el.components.fakeComponent);
@@ -1050,8 +1050,8 @@ suite('a-entity', function () {
10501050
var materialAttribute = 'color: #F0F; transparent: true';
10511051
var nativeSetAttribute = HTMLElement.prototype.setAttribute;
10521052
var nativeGetAttribute = HTMLElement.prototype.getAttribute;
1053-
this.sinon.stub(el, 'setAttribute', nativeSetAttribute);
1054-
this.sinon.stub(el, 'getAttribute', nativeGetAttribute);
1053+
this.sinon.replace(el, 'setAttribute', nativeSetAttribute);
1054+
this.sinon.replace(el, 'getAttribute', nativeGetAttribute);
10551055
el.setAttribute('material', materialAttribute);
10561056
el.initComponent('material', '', true);
10571057
assert.equal(el.getAttribute('material'), materialAttribute);
@@ -1138,7 +1138,7 @@ suite('a-entity', function () {
11381138

11391139
box.setAttribute('geometry', {primitive: 'box'});
11401140
component = box.components.geometry;
1141-
removeSpy = this.sinon.stub(component, 'remove', () => {});
1141+
removeSpy = this.sinon.replace(component, 'remove', () => {});
11421142

11431143
box.removeComponent('geometry');
11441144
assert.notOk(removeSpy.called);

0 commit comments

Comments
 (0)