2

I have the following error, while running jest tests:

Cannot find module '../build/Release/magic' from 'index.js'

  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:191:17)
  at Object.<anonymous> (node_modules/mmmagic/lib/index.js:3:13)

If I run an app as normal, it works without problems, but when trying to run Jest tests throws error above. Maybe someone has a similar issue. Thank you.

NodeJS: 8.11,

default_configuration: 'Release'

Vladyslav Moisieienkov
  • 4,118
  • 4
  • 25
  • 32

1 Answers1

3

mmmagic in build/Resolve/magic imports file magic.node, but Jest only imports files with extensions that specified in moduleFileExtensions. So solution is simple, just add node to moduleFileExtensions:

"moduleFileExtensions": [
    "js",
    "json",
    "ts",
    "node"
],
Vladyslav Moisieienkov
  • 4,118
  • 4
  • 25
  • 32