Created
January 21, 2014 17:23
-
-
Save knownasilya/8544236 to your computer and use it in GitHub Desktop.
ember testing mocha..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Body --> | |
<div id="mocha"></div> | |
<div id="ember-container"></div> | |
<script src="assets/bower_components/chai/chai.js"></script> | |
<script src="assets/bower_components/mocha/mocha.js"></script> | |
<script src="../assets/scripts/application.js"></script> | |
<script src="assets/bower_components/ember-mocha-adapter/adapter.js"></script> | |
<script type="application/javascript"> | |
Ember.Test.adapter = Ember.Test.MochaAdapter.create(); | |
App.rootElement = '#ember-container'; | |
App.setupForTesting(); | |
App.injectTestHelpers(); | |
mocha.setup('bdd'); | |
</script> | |
<!-- Include tests here --> | |
<script src="test.js"></script> | |
<script type="application/javascript"> | |
mocha.run(); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var expect = chai.expect; | |
// Run before each test case. | |
beforeEach(function () { | |
// Put the application into a known state, and destroy the defaultStore. | |
// Be careful about DS.Model instances stored in App; they'll be invalid | |
// after this. | |
// This is broken in some versions of Ember and Ember Data, see: | |
// https://github.com/emberjs/data/issues/847 | |
Ember.run(function () { | |
App.reset(); | |
}); | |
// Display an error if asynchronous operations are queued outside of | |
// Ember.run. You need this if you want to stay sane. | |
Ember.testing = true; | |
}); | |
// Run after each test case. | |
afterEach(function () { | |
Ember.testing = false; | |
}); | |
describe('Test URL navigation', function () { | |
it('policymaker should display panel', function (done) { | |
visit('/map/policy').then(function () { | |
expect(find('h2:contains("PolicyMaker")')).to.be.ok; | |
done(); | |
}); | |
}); | |
it('CAI Survey page should have title', function (done) { | |
visit('/survey').then(function () { | |
expect(find('h2:contains("CAI Survey")')).to.be.ok; | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answer: Remove
done()
statements when usingember-mocha-adapter
.