mercredi 29 mars 2017

How to test javascript code that calls window objects

I have a bit of javascript that is as follows

  if (Notification.permission !== 'granted') {
    return Notification.permission
  } 

When I run mocha tests on some code that uses this function the test fails:

ReferenceError: Notification is not defined

I thought doing:

    sinon.stub(Notification, 'permission')

would make this work but I still get the same error.

How do I prevent this error?

Aucun commentaire:

Enregistrer un commentaire