Question

In the jquery-jasmine documentation (I've listed the exact revision of the docs in case they change).

It describes:

toContainHtml(string)

expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>')

toHaveHtml(string)

expect($('<div><span></span></div>')).toHaveHtml('<span></span>')

When should I use toContainHtml() and when should I use toHaveHtml()? From the examples I can't tell the difference.

Was it helpful?

Solution

Judging by this ticket on jasmine-jquery's github page

toHaveHtml() is more exacting using a == check

Whereas toContainHtml() uses an indexOf() check.

However the example in the documentation doesn't really demonstrate this, so I'm still not certain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top