qinshenxue / vue-icon

Maybe it is the smallest vue component that contains all the feather icons
https://qinshenxue.github.io/vue-icon/
MIT License
54 stars 12 forks source link

'Unexpected token export' error when using vue-icon in Jest unit testing #2

Open ghost opened 6 years ago

ghost commented 6 years ago

Version

2.0.0

Steps to reproduce

<v-icon v-if="item.icon" v-bind:name="item.icon"></v-icon>
import Vue from 'vue'
import { mount } from '@vue/test-utils'

import router from '@/router'
import VueI18n from 'vue-i18n'
import Vuelidate from 'vuelidate'
import BootstrapVue from 'bootstrap-vue'
import feather from 'vue-icon'

import DropdownIcon from '@/components/molecules/DropdownIcon'

describe('DropdownIcon', () => {

    const wrapper = mount(DropdownIcon)
    const vm = wrapper.vm

    it('should be a Vue instance', () => {
        expect(wrapper.isVueInstance()).toBeTruthy()
    })

})

What is expected

vue-icon is imported and used in component - so component can be tested correctly.

What is actually happening

 FAIL  test\unit\specs\DropdownIcon.spec.js
  ● Test suite failed to run

    C:\Users\User\Development\project_name\node_modules\vue-icon\lib\vue-feather-plugin.esm.js:133
    export default install;
    ^^^^^^

    SyntaxError: Unexpected token export

       6 | import Vuelidate from 'vuelidate'
       7 | import BootstrapVue from 'bootstrap-vue'
    >  8 | import feather from 'vue-icon'
       9 |
      10 | import DropdownIcon from '@/components/molecules/DropdownIcon'
      11 |

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
      at Object.<anonymous> (test/unit/specs/DropdownIcon.spec.js:8:16)

Other information

When I run npm run dev the code compiles and builds out correctly, and vue-icon works as intended. I only get this problem when I run npm run unit.

My other tests on components which don't use vue-icon work as intended. I believe this has something to do with vue-icon using uncompiled ES6 code? Please correct me if I'm wrong.

Thank you for your time!

qinshenxue commented 6 years ago

thanks for your feedback. I will fix the problem as soon as possible.

bitsnaps commented 8 months ago

Looks like this project is no longer maintained, I'm not sure if it's support Vue 3, the best icon package -IMO- for Vue at the moment is @iconify/vue by far.