Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Cannot import library for testing #69

@sniperadmin

Description

@sniperadmin

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

  1. Test file should import the module/lib
  2. 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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions