karma: text! plugin could not load the HTML template during test
It appear when using Karma with Require.js, it cannot load text! plugin. I am getting
Error: /base/app/assets/javascripts/src/client/templates/show.html HTTP status: 404
But if I change the file extension to show.js, it can be loaded. It appear that it only accept JavaScript file?
Here is the proof-of-concept repo to product this: https://github.com/mech/front_end_demo
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 21 (1 by maintainers)
FWIW: I’m using karma 0.12.16 and karma-requirejs 0.2.2 and for me it was just enough to add this line to
karma.conf.jsto successfully load a template via the text plugin and prevend a404:(files: [{pattern: 'templates/*.html', included: false}])@ievgenneiman:
text! requirejs can’t load html in Karma solution
<script src="...">, so this would lead into “unexpected token” error.__html__['some.html']. This is why Karma servestest.html.jsinstead oftest.html.templates/x.html, but not include it, so that require.js can fetch it on its own.depsto load test cases, could meet with unexpected<error. So use a module to load all test cases.