11

I am using ace code editor package which uses a webpack-resolver.js file in its package that has inline file-loader! in each require statement e.g.

This works fine for my webpack config and everything builds fine when using it however when I go to use jest, it isn't recognizing the file-loader! and fails

require('file-loader!./src-noconflict/ext-beautify.js')

Is there something in the jest config to fix this?

I get the following error

 Cannot find module 'file-loader!./src-noconflict/ext-beautify.js' from 'webpack-resolver.js'
skyboyer
  • 22,209
  • 7
  • 57
  • 64
Ruegen
  • 605
  • 9
  • 35
  • I have the same problem, our code is using `webpack-resolver` and we're using jest for testing. The problem is jest (at least in our configuration) is not using webpack to resolve modules. And it has no implementation of `file-loader` which is a webpack feature – stralsi Dec 03 '19 at 14:41

1 Answers1

14

I added: "ace-builds": "<rootDir>/node_modules/ace-builds" in Jest moduleNameMapper, and it worked for me.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158