我的Jasmine代码出了什么问题?

时间:2015-08-07 06:28:21

标签: javascript jquery html jasmine jasmine-jquery

以下是我用茉莉花编写的代码,我在这里观看教程:Jasmine-jquery tutorial

茉莉花:

describe('example', function() {
var elem;

beforeEach(function() {
    elem = $('<div id="container"><p>Hello World</p></div>');
});

it('allows to search css', function() {
    expect(elem).toBeMatchedBy('#container');
    expect(elem).toHaveText('Hello World');
    expect(elem).toHaveHtml('<p></p>');
});

这是我的SpecRunner HTML头:

    <head>
  <meta charset="utf-8">
  <title>Jasmine Spec Runner v2.3.4</title>

  <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.3.4/jasmine_favicon.png">
  <link rel="stylesheet" href="lib/jasmine-2.3.4/jasmine.css">

  <script src="lib/jasmine-2.3.4/jasmine.js"></script>
  <script src="lib/jasmine-2.3.4/jasmine-html.js"></script>
  <script src="lib/jasmine-2.3.4/boot.js"></script>
  <!-- include source files here... -->

  <script src="src/yeahboy.js"></script>
  <script src="src/jquery.js"></script>
  <script src="src/jasmine-jquery.js"></script>
  <!-- include spec files here... -->

  <script src="spec/exampleSpec.js"></script>

</head>

我在这里遗漏了什么吗?这是我的错误。 enter image description here

1 个答案:

答案 0 :(得分:0)

您必须将'#containers'替换为'#container'。