Skip to content

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

Open
@ghost

Description

Version

2.0.0

Steps to reproduce

<v-icon v-if="item.icon" v-bind:name="item.icon"></v-icon>
  • Running the following test:
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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions