以下是我用茉莉花编写的代码,我在这里观看教程: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>
答案 0 :(得分:0)
您必须将'#containers'替换为'#container'。