karma-html2js-preprocessor
Preprocessor for converting HTML files into JS strings.
Note: If you are using AngularJS, check out karma-ng-html2js-preprocessor.
Installation
The easiest way is to keep karma-html2js-preprocessor
as a devDependency in your package.json
.
You can simple do it by:
npm install karma-html2js-preprocessor --save-dev
Configuration
// karma.conf.jsmodule { config;};
How does it work ?
This preprocessor converts HTML files into JS strings and publishes them in the global window.__html__
, so that you can use these for testing DOM operations.
For instance this template.html
...
something
... will be served as template.html.js
:
window__html__ = window__html__ || {};window__html__'template.html' = '<div>something</div>';
See the end2end test for a complete example.
For more information on Karma see the homepage.