我是Jasmine-jQuery的新手。我尝试使用fixture HTML,但测试没有通过。
夹具.html:
<html>
<body>
<p id="0">
</p>
</body>
</html>
fake_code_for_question_spec.coffee:
describe "FakeCodeForQuestion", ->
describe "with HTML fixture", ->
beforeEach ->
loadFixtures "fixture.html" ### Load Fixture
@obj = new FakeCodeForQuestion
describe "#addText", ->
beforeEach ->
@obj.addTextToParagraph0() ### Change DOM
it "should add text", ->
expect($('p#0')).toHaveText "text" ### Get Changed DOM
fake_code_for_question.coffee:
root = exports ? this
class root.FakeCodeForQuestion
addTextToParagraph0: ->
$('p0').text "text"
茉莉花结果:
Expected '<p id="0"> </p>' to have text 'text'.
谢谢你的好意。