running Js test getting error window is undefined

running JS tests using karma + jasmine

I get an error ‘window’ is not defined, I’ve added defensive code to detect browser like so

if ((typeof window !== 'undefined') && window['test']) {

but still get an error , how can type of window be defined and the window be undefined at the same time ?

Edit :

The exact error is : ‘window’ is not defined


What was missing was this

/*jshint browser: true*/

Leave a Reply

Your email address will not be published. Required fields are marked *