vue-babylonjs
vue-babylonjs copied to clipboard
Cannot import library for testing
Bug story When I import the library inside my test file:
// example.spec.ts
import { .... } from 'vue-babylonjs';
//OR
import vb from 'vue-babylonjs';
the following bug prevents excecution
FAIL tests/unit/example.spec.ts
● Test suite failed to run
ReferenceError: performance is not defined
at Object.56.../collision/AABB (node_modules/vue-babylonjs/dist/umd.js:100938:25)
at s (node_modules/vue-babylonjs/dist/umd.js:93617:21)
at node_modules/vue-babylonjs/dist/umd.js:93619:22
at Object.2.../package.json (node_modules/vue-babylonjs/dist/umd.js:93715:20)
at s (node_modules/vue-babylonjs/dist/umd.js:93617:21)
at e (node_modules/vue-babylonjs/dist/umd.js:93625:44)
at node_modules/vue-babylonjs/dist/umd.js:93627:8
at node_modules/vue-babylonjs/dist/umd.js:93603:24
at node_modules/vue-babylonjs/dist/umd.js:93604:6
at createCommonjsModule (node_modules/vue-babylonjs/dist/umd.js:93251:39)
Expected behavior
- Test file should import the module/lib
- Test file should access the components
e.g. <Scene />
without stubbing them
Screenshots (optional)
To test my current component, I have to stub all the vb
components to skip them.
Here is a full test example:
import Vue from 'vue';
import Vuetify from 'vuetify';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import HelloWorld from '../../src/components/babylon/HelloWorld.vue';
describe('HelloWorld.vue', () => {
Vue.use(Vuetify);
const vuetify = new Vuetify({});
let wrapper: any;
const localVue = createLocalVue();
beforeEach(() => {
wrapper = shallowMount(HelloWorld, {
localVue,
vuetify,
stubs: [
'Scene',
'Camera',
'Ground',
'Sphere',
'Animation',
'HemisphericLight',
'Physics',
'Entity',
'Key',
'Material',
'Texture',
'Property',
],
});
});
afterEach(() => {
wrapper.destroy();
});
test('renders props.msg when passed', () => {
const title = wrapper.find('v-card-title-stub');
expect(title.text()).toBe('Test Gravity');
});
});
Environment (please complete the following information):
- Device: [Desktop]
- OS: [Windows10]
Hello @sniperadmin I'm facing the same issue. Did you find any solution ?
Regards.