mardi 26 mai 2015

Testing in a page context

I need some guidance on how to run js unit tests in web page context.

I have a page where graphs will be drawn using a 3rd party JS library. Also, there will be some filtering logic written by me - I want to test this piece.

The challenge I have is that I have to have a DOM present for this library to work, and I'm not quite sure how to run tests in this context.

It all looks something like this:

On a web page I have a div. Then in JS file I will say

var drawing = DrawStuffIn(getElementByid("my-div"));
drawing.FilterBy(something);
var filteredItems = drawing.GetFilteredItems();

At this point I want to make sure that filteredItems contain what I expect.

I was looking at using PhantomJS and Jasmine, but not quite sure how to fit it all together.

Aucun commentaire:

Enregistrer un commentaire