Jest encountered an unexpected token: <template>



  • After upgrading to Quasar 1.14.5 suddenly all my component unit tests are failing. Is there an easy fix?



  • Went back to before the Quasar upgrade, but still see the problem.
    Then re-installed jest like this, but still have the same problem…
    $ quasar ext remove @quasar/testing-unit-jest
    $ quasar ext add @quasar/testing-unit-jest

    Why is jest not recognizing <template> ??



  • Well this is just weird!
    Vetur was showing every line with error in two of my components. After trying many things, I accidentally discovered that changing the filename fixed the problem!
    So TreeSelect.vue was full of errors starting with the <template> tag, but renaming to SelectTree.vue made them all go away!
    And now, my jest tests are working again too!
    I’ll leave this post up in case someone else falls into this weird situation.


Log in to reply