karma-inject-html
v0.0.1
Published
inject html markup automatically for each test
Downloads
273
Maintainers
Readme
karma-inject-html
This karma plugin is useful when you switching to karma and don't want to rewrite all your tests because karma don't provide a automatically HTML page injection for your tests.
You can inject markup from a file or you can write the markup directly into the karma config.
install
$ npm install karma-inject-htmlUsage
example karma.config.js
module.exports = function(config) {
config.set({
preprocessors: {
'test/*.js': ['inject-html']
},
injectHtml: {
file: 'test/test-container.html'
}
}injectHtml (options object)
you can set either a file or the raw markup
options.file: 'file/to/the/file.html'
(relative to the basePath)
options.raw: '<div id="test-content"><div>'
What is with karma-html2js-preprocessor?
There is alread a plugin which converts HTML files into JS strings, but it only provides
them via the global window scope.
So you still need to load your markup in every test.
How it works?
The template is injected via JavaScript by using document.body.appendChild
before each test starts.
