Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import library for testing #69

Open
sniperadmin opened this issue Jun 26, 2020 · 1 comment
Open

Cannot import library for testing #69

sniperadmin opened this issue Jun 26, 2020 · 1 comment

Comments

@sniperadmin
Copy link

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]
@thibautflottat
Copy link

Hello @sniperadmin
I'm facing the same issue. Did you find any solution ?

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants