aframe: Tests failing locally

I have test failing locally and can’t figure out why. Both on Chrome and Firefox. They seem to work on the repo test automation.

I narrowed down one of the issues. This test:

https://github.com/aframevr/aframe/blob/master/tests/components/gltf-model.test.js#L21

The gltf model loads but when setting the mesh object in this this line:

https://github.com/aframevr/aframe/blob/master/src/components/gltf-model.js#L48

The obj instanceof THREE.Object3D test in the line below fails throwing an error and making the test fail:

https://github.com/aframevr/aframe/blob/master/src/core/a-entity.js#L128

I can reproduce in console during the test execution but don’t know why it’s failing. I’m pretty puzzled because only happens in the context of the tests and cannot reproduce outside. Could be some of the polyfills or monkey patching we’re doing

@vincentfretin Any ideas? Thanks

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 50 (50 by maintainers)

Most upvoted comments

Nice, so context for what was happening:

  • The karma.conf.js added src as one of the folder names to search in.
  • When three.mjs imports three it resolves to node_modules/three/build/three.module.js as it should
  • When three.mjs imports the GLTFLoader it correctly resolves it to node_modules/three/examples/jsm/loaders/GLTFLoader.js.
  • When GLTFLoader imports from three it resolved incorrectly to node_modules/three/src/Three.js
    • It starts crawling up the path from node_modules/three/examples/jsm/loaders/GLTFLoader.js till it finds either a src/ or node_modules/ folder.
    • When it finds the src/ folder in node_modules/three/ it checks if it can find “three”, which it finds in the form of node_modules/three/src/Three.js

What strikes me as odd is that it accepts Three.js for the identifier three despite the capitalization difference. My guess is that under Linux it rejects it, but under Mac OS somehow accepts it. Either way, we don’t want to search for any src folder, but a specific one. Hence replacing it with an absolute path fixes it. (Relevant webpack docs: resolve.modules)

Could you try changing the following in karma.conf.js:36:

-webpackConfiguration.resolve.modules = ['src', 'node_modules'];
+webpackConfiguration.resolve.modules = [path.resolve(__dirname, '../src'), 'node_modules'];

That did the trick! Thanks so much for the patience and sticking with me. Super super appreciated!