I'm running tests on phantomjs via the karma runner and some of my code makes ajax calls which all fail with a 404.
I've struggled with where to place the file (see: Including libraries fails - what is document root?) but I came across a post (Loading external file from Karma/Jasmine test) that indicates I can configure the karma web server to serve other files.
in particular the ajax calls are attempting to load files from the node_modules
directory so I've configured the karma.config.js
like this:
files: [{
pattern: 'node_modules/*',
served: true,
included: false
}]
and my ajax calls look generally like this (I've placed a blah.js
in the directory for testing):
$.ajax({url: 'node_modules/blah.js', ...});
but still it doesn't work. what am I missing?