Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Jest在vue测试UTIL中为ThreeJS导入错误_Javascript_Vue.js_Three.js_Jestjs - Fatal编程技术网

Javascript 使用Jest在vue测试UTIL中为ThreeJS导入错误

Javascript 使用Jest在vue测试UTIL中为ThreeJS导入错误,javascript,vue.js,three.js,jestjs,Javascript,Vue.js,Three.js,Jestjs,我试图让我的jest测试(用于VueJS SPA)正常工作,因为我在一个组件中集成了三个.js,但我遇到了一些问题。当我运行应用程序时,一切正常,但测试因错误而崩溃: /Users/Whomever/FE/node_modules/three/examples/jsm/controls/OrbitControls.js:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__

我试图让我的jest测试(用于VueJS SPA)正常工作,因为我在一个组件中集成了三个.js,但我遇到了一些问题。当我运行应用程序时,一切正常,但测试因错误而崩溃:

/Users/Whomever/FE/node_modules/three/examples/jsm/controls/OrbitControls.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import {
                                                                                             ^^^^^^

SyntaxError: Cannot use import statement outside a module
最后,我还尝试在index.html文件中导入三个,没有成功。现在我没有选择了

问题是从使用Three.js开始的,在此之前所有的测试都是功能性的


提前感谢您的帮助

不应从examples文件夹导入OrbitControl。这是一个自定义函数

尝试将需要的示例代码复制/粘贴到项目中的新TypeScript类中。然后您应该能够正确导入它。请注意,它们可能都导入了三个,因此您可能会遇到上下文问题

import Vue from "vue";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
import * as THREE from "three";
export default Vue.extend({
  name: "Some3DComponent",
  components: {}
  data: () => ({
    displayModes: [],
    viewWidth: 100,
    viewHeight: 100,
    modelClickableElements: null,
    has3dModel: false,
    ground: null,
    animationFrame: null,
    editorMode: null,
    renderGround: true,
    scales: null
  }),
//Rest of the code that calls THREE and OrbitControls

    });