My project has external dependecies so I configured webpack like that:
externals:{
'd3':'d3',
'another-external-dep': 'another-external-dep'
}
And then in the code I require the dependecies like that:
var someProp = require('another-external-dep').someProp
.
All good until I integrated karma.
So karma when run the tests fail to find the module another-external-dep
clearly because it is an external dependecies and I did not included in the karma config on the list of files.
How can I mock another-external-dep
so require('another-external-dep')
returns a mock? Also where I can specify this mock, in the config or in the mock?
You can link to external dependencies during karma tests by including dependencies in the array of
files
inkarma.config.js
.This makes the dependencies available in the global context, which you can then reference from the webpack'd files, replicating your development context.