guardian / sbt-jasmine-plugin

An SBT plugin for running jasmine tests in your build.
23 stars 28 forks source link

angular.js TypeError: Cannot call method "charAt" of undefined #17

Open joescii opened 10 years ago

joescii commented 10 years ago

I'm attempting to utilize this plugin to execute tests against some angular-based code. Including angular.js script via EnvJasmine.loadGlobal is sufficient to reproduce this issue. I have verified this issue occurs in angular 1.2.1-1.2.7. It does NOT happen if using angular 1.2.0

The plugin errors with this message: TypeError: Cannot call method "charAt" of undefined

I believe the error occurs on this line where the urlParsingNode.pathname object is undefined.

The urlParsingNode is instantiated on this line in angular. Angular creates the document anchor, and later sets the href attribute. While this must certainly work well in browsers, the returned object has pathname undefined. The idea is that an anchor tag should correctly handle URL parsing for angular, but in the Rhino environment... no dice.

My project does NOT utilize require.js. I've confirmed this occurs on both Windows and Linux platforms.

joescii commented 10 years ago

Also, I tried pointing window.location to a local html file in hopes that would allow document to behave as in a browser environment, but that didn't help.

joescii commented 10 years ago

Asked this question on Stackoverflow.