Mocking document

1,109 views
Skip to first unread message

Trevor Lalish-Menagh

unread,
Nov 16, 2010, 11:05:12 AM11/16/10
to Jasmine
Hello all,

I am integrating Jasmine into my maven build process and have run into
a puzzling problem.

I am testing a library that sets cookies and local storage. To verify
that my library works, I check document.cookie to see if the cookie
was set.

Since cookies don't exist locally, I can only get the tests to pass if
I put my Jasmine HTML file on a web server (I use Sinatra).

But, it seems that when I run the tests in my maven build process,
they run as if locally, thus they break.

Barring spinning up a web server to run the tests in my build process,
does anyone know how to mock document?

I tried adding:
beforeEach(function () {
document = {"cookie": ""};
});

but it seems I am not allowed to override document. Any ideas?

Yours,
Trevor

Jeremy Lightsmith

unread,
Nov 16, 2010, 12:36:55 PM11/16/10
to jasmi...@googlegroups.com
how about document["cookie"] = ...?

----
Jeremy Lightsmith
Helping Software Teams Get More Productive with tools like Agile, Lean, & Rails
312-953-1193
http://jeremylightsmith.com/
http://facilitationpatterns.org/ (book in progress)
http://www.linkedin.com/in/jeremylightsmith




--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To post to this group, send email to jasmi...@googlegroups.com.
To unsubscribe from this group, send email to jasmine-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jasmine-js?hl=en.


Davis Frank

unread,
Nov 16, 2010, 2:05:12 PM11/16/10
to jasmi...@googlegroups.com
Maybe something is assuming that document is on window? So build up your window global object with a document property with a cookie property?

--dwf
Reply all
Reply to author
Forward
0 new messages