[Vue] Jest encountered an unexpected tokenエラーに対処する [Jest]

Vueの外部ライブラリを使ったComponentのユニットテストをしようとしたところ、エラーが出た。

ちなみにエラーの出たライブラリはvue-knob-control

 ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

以下略

以下で解決した。

https://github.com/vuejs/vue-jest/issues/185

公開されているライブラリの中にはTypeScriptやフレームワークのコードがトランスパイルされないまま公開されている場合があり、Jestはそのモジュールを解析できないためシンタックスエラーになるようだ。

https://jestjs.io/docs/en/23.x/configuration#transformignorepatterns-arraystring

今回の場合、package.jsonに以下を追加した。

{
   "jest": {
      ...
      "transformIgnorePatterns": [ "/node_modules/(?!vue-knob-control)" ]
   }
}