Reputation: 5001
I am attempting to set up tests for a Polymer application using Karma. However an essential element of those tests is the basic html fixture.
However, when I get to the code that tries to read the __html__
array. this gives an undefined.
I have included all the key files in a gist https://gist.github.com/akc42/121c619ef2476ce82086
Because polymer.js needs to be loaded as the first script in head, and because Karma includes all the files as script tags, I have a PolymerTests.js script which adds the Polymer element to the head. It also defines a load fixtures function which should read one of the files that have been placed in __html__
and adds it to a container div in the main body of the test page.
var container; //Used to hold fixture
PolymerTests.loadFixture = function(fixture,done) {
container = document.createElement("div");
container.innerHTML = __html__[fixture];
document.body.appendChild(container);
waits(0);
done();
};
This is called in a beforeEach routine for a specific test.
However when I get there, I get undefined.
EDITED
The question of course is has anyone any idea how to work out what I am doing wrong. I tried a debug session, but can't see window.__html__
defined anywhere.
Upvotes: 0
Views: 490
Reputation: 416
Probably you also use ng-html2js preprocessor. And they have ugly thing in index.js
:
// TODO(vojta): remove this in 0.11
'preprocessor:html2js': ['factory', require('./html2js')]
After removing it, it will work.
Upvotes: 0
Reputation: 5001
In order for the pre-processor to actually put files into the __html__
array is is necessary to ensure the files are also included in the "files" section of the karma configuration file. If there are not included there, they won't be put into the array.
Upvotes: 1