VMois
VMois

Reputation: 4708

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

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'

Upvotes: 2

Views: 2013

Answers (1)

VMois
VMois

Reputation: 4708

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"
],

Upvotes: 3

Related Questions