[Vuejs]-Vue/cli-plugin-unit-jest cannot find module

0👍

This issue occurs because by default, jest doesn’t transform anything from /node_modules.

What worked for me is this:

replace import { WebRTCAdaptor } from '@antmedia/webrtc_adaptor'

with import { WebRTCAdaptor } from '../../node_modules/@antmedia/webrtc_adaptor/src/main/webapp/js/webrtc_adaptor.js'

And in package.json add:

"jest" : {
  "preset": "@vue/cli-plugin-unit-jest",
  "transformIgnorePatterns": [
    "/node_modules/(?!@antmedia).+\\.js$"
  ]
},

Of course replace @antmedia with the package you want to import.

Leave a comment