P
P
Peter2015-12-24 11:40:21
Behavior-driven development
Peter, 2015-12-24 11:40:21

Why does karma give the error "TypeError: 'null' is not an object..."?

For modular assembly, browserify is used.
Test framework jasmine.
Test runner karma
Browser phantom.js
Everything works great until the code starts manipulating the DOM.
If the code contains the expression

var textHeader = document.getElementById('textHeader');
textHeader.innerHTML = "text in element";

Then Karma throws an error TypeError: 'null' is not an object (evaluating 'textHeader.innerHTML = "text in element"') ;
It seems that for this it was necessary to connect the html file and the karma-html2js-preprocessor module in the karma config, but this connection did not give anything. Although, maybe I didn't do something right.
The code can be viewed here https://github.com/volkovpv/blackboard/tree/develop , develop branch.
What could be the problem and how to fix it?
PS the build folder www is registered in the settings, which is not in the repository. But that's where karma sees the code to test.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question