2

I'm currently testing a component that relies on a an external script with webpack externals.

DBPanel.js:

import React, { PureComponent } from 'react';
import $ from 'jquery';

And the webpack externals file looks like this:

webpack.config.js:

externals: {
    jquery: "jQuery",
    Materialize: "Materialize"
}

When I import the the file in my test import DBPanel from '../components/DBPanel'; I get this error:

Error: Cannot find module 'jquery'
Yago Azedias
  • 4,480
  • 3
  • 17
  • 31
Jerry Tsui
  • 21
  • 2
  • 3
  • Please see this answer: https://stackoverflow.com/questions/46655678/how-to-test-a-webpack-bundle-that-has-external-dependencies – Luke H Jul 29 '21 at 22:06

0 Answers0