【发布时间】:2014-08-06 19:46:21
【问题描述】:
第二个测试,说存在一个 h3 元素,显然应该失败,但没有。怎么回事?
使用 Mocha、Chai、Ember 和 ember-mocha-adapter,我创建了这个简单的示例:http://jsfiddle.net/signer247/UD2D3/4/。
HTML
<div id="mocha"></div>
<hr/>
<div id="ember-testing"></div>
<script type="text/x-handlebars" data-template-name="application">
<h1>Ember.js Testing with Ember Mocha Adapter</h1>
</script>
咖啡脚本
App = Em.Application.create()
App.Router.map ->
@route 'index', path: '/'
App.rootElement = '#ember-testing';
App.setupForTesting()
App.injectTestHelpers()
Ember.Test.adapter = Ember.Test.MochaAdapter.create()
chai.should()
describe 'Changing a site via visit in the test with andThen helper', ->
beforeEach ->
App.reset()
visit('/')
it 'should work', ->
andThen ->
$c = $(App.rootElement)
$c.find('h1').should.exist
it 'should fail', ->
andThen ->
$c = $(App.rootElement)
$c.find('h3').should.exist
$(document).ready ->
mocha.run();
我的 JSFiddle:http://jsfiddle.net/signer247/UD2D3/4/
我根据这个例子构建了我的 JSFiddle:http://jsfiddle.net/UD2D3/1/
这是 ember-mocha 适配器:https://github.com/teddyzeenny/ember-mocha-adapter
【问题讨论】:
标签: javascript ember.js coffeescript mocha.js chai