karma-jasmine-dom
v1.0.1
Published
Set of 19 jasmine custom matchers configured for karma to test html DOM.
Maintainers
Readme
Description
karma-jasmine-dom adapts the jasmine-dom-custom-matchers package to the karma framework.
- All the available matchers are described in the
jasmine-dom-custom-matchersdocumentation - See also
karma-htmlto test html files in the browser withkarma[link]
Usage
- Run
npm install karma-jasmine-dom - Add the following frameworks into your
karma.conf.jsfile:
module.exports = function(config) {
config.set({
//karma config here
frameworks: ['jasmine-dom','jasmine']
});
};Mind that
jasmine-dommust precedejasmine(as above) in theframeworksarray. The frameworks are loaded from right to left and thejasminemust be loaded first, as thejasmine-domarejasminecustom matchers.
Tests
Load the matchers with jasmine.addMatchers native method:
describe("The <body>",function(){
beforeAll(function(){
jasmine.addMatchers(DOMCustomMatchers);
});
it("should be the part of DOM",function(){
expect(document.body).toBeDocumentNode();
});
});