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

Vuetify and testing #3456

Closed
juhasev opened this issue Mar 3, 2018 · 4 comments
Closed

Vuetify and testing #3456

juhasev opened this issue Mar 3, 2018 · 4 comments

Comments

@juhasev
Copy link

juhasev commented Mar 3, 2018

Versions and Environment

Vuetify: 1.0.4
Vue: 2.5.13
Browsers: Chrome 64.0.3282.186
OS: Mac OS 10.13.3

Steps to reproduce

Create minimal component using toolbar and tooltip:

<template>

    <v-toolbar card>
        <v-toolbar-title class="title">User Manager</v-toolbar-title>
        <v-spacer/>

        <v-tooltip top>
            <v-btn slot="activator" icon color="primary">
                <v-icon>person_add</v-icon>
            </v-btn>
            <span>Invite new user</span>
        </v-tooltip>

    </v-toolbar>

</template>

Next in your test mount the component twice:

import {shallow, createLocalVue} from '@vue/test-utils';
import Component from '../modules/UserManager/components/VuetifyError.vue';
import Vuex from 'vuex';
import Vuetify from 'vuetify';
import sinon from 'sinon';
import {expect} from 'chai';

const localVue = createLocalVue();

localVue.use(Vuex);
localVue.use(Vuetify);

describe('VuetifyError', () => {

    it('first mount', () => {
        const wrapper = shallow(Component, {localVue});
    });

    it('second mount', () => {
        const wrapper = shallow(Component, {localVue});
    });
});

Expected Behavior

No errors

Actual Behavior

First shallow mount works fine, no errors. However the second mount results into errors. I believe data-app bug has been in other components and has been fixed else where but these are still not working. Something must be changing in the global scope...

[Vuetify] Unable to locate target [data-app] in "v-tooltip"
[Vue warn]: Error in config.errorHandler: "TypeError: window.requestAnimationFrame is not a function"
TypeError: window.requestAnimationFrame is not a function
    at VueComponent.mounted (/Users/juhavehnia/Code/platform/.tmp/mocha-webpack/1520102743411/webpack:/node_modules/vuetify/dist/vuetify.js:1723:1)
    at callHook (/Users/juhavehnia/Code/platform/.tmp/mocha-webpack/1520102743411/webpack:/node_modules/vue/dist/vue.js:2895:1)

Reproduction Link

https://jsfiddle.com/

Other comments

My apologies for not putting this up as a running example. I took this out of a bigger project and stripped it down to the bare minimum. Should be easy to plug in and run.

@johnleider
Copy link
Member

This is something you need to expect when testing certain components. You can see how we handle this in our tests.

@gangsthub
Copy link

If you are using jest, instead of jasmine; you can overwrite the global.console:

// tests/utils.js <-- Or whatever you want to call it

global.console = {
  ...global.console, // get the default values first and overwrite the ones that we want:
  error: jest.fn(),
  warn: jest.fn(),
  info: jest.fn(),
}

And import it in the tests needed ;)

@Oliboy50
Copy link

@johnleider could you post your "way of handling this" instead of letting us search for it?

Or either fix the issue?

couldn't you set a if (!data-app) return; somewhere to avoid warnings?

this is annoying and I don't like to do crappy stuff in my tests to avoid such warnings

@johnleider
Copy link
Member

const el = document.createElement('div')
el.setAttribute('data-app', true)
document.body.appendChild(el)

@vuetifyjs vuetifyjs locked as resolved and limited conversation to collaborators Jul 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants