[Vuejs]-Vue-2 Jest-24 running test error, SyntaxError: Unexpected character '#'

0👍

This is likely related to you using a shorthand template statement in your .vue component. Vue 2.x has an issue with using pug and shorthand template statements when running tests (See: https://github.com/vuejs/vue-jest/issues/175)

From the error, it may be in your map component. There are two options on resolving your issue.

First one is as described in the GitHub, adding the following to your jest.config.js file.

module.exports = {
  // ...
  globals: {
    'vue-jest': {
      pug: { doctype: 'html' }
    }
  }
}

The second option, in case the above does not work (which it did not for me as there is a bug in some package I cannot resolve) is to not use shorthand template tags.

Try finding a statement that looks like template(#someslot) and replace it with template(#someslot="") or template(someslot="").

Leave a comment