Last active
August 29, 2015 14:26
-
-
Save oliverbarnes/1385658fb7376bcdd687 to your computer and use it in GitHub Desktop.
ember model unit test error
This file contains 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
//tests/unit/models/proposal.js | |
/* jshint expr:true */ | |
import { | |
describe, | |
describeModule, | |
it, | |
beforeEach, | |
afterEach | |
} from 'ember-mocha'; | |
import { expect } from 'chai'; | |
import Resource from '../../../models/proposal'; | |
var supports; | |
describeModule('model:proposal', 'Unit | Model| Proposal',{}, function() { | |
beforeEach(function() { | |
Resource.prototype.container = this.container; | |
// Use a non-standard name, i.e. pluralized instead of singular | |
this.container.register('model:proposalz', Resource, {}); | |
}); | |
afterEach(function() { | |
delete Resource.prototype.container; | |
}); | |
describe('#toggleSupport', function() { | |
describe('when proposal is not supported yet', function() { | |
it('adds a support to it', function() { | |
expect(this.subject().get('supports')).to.eql([]); | |
this.subject().toggleSupport; | |
expect(this.subject().get('supports')).to.eql(supports); | |
}); | |
}); | |
}); | |
}); | |
//error | |
not ok 65 PhantomJS 1.9 - Unit | Model| Proposal TestLoader Failures client/tests/unit/models/proposal-test: could not be loaded | |
--- | |
message: > | |
'undefined' is not a function (evaluating 'ember_mocha.beforeEach') | |
stack: > | |
TypeError: 'undefined' is not a function (evaluating 'ember_mocha.beforeEach') | |
at http://localhost:7357/assets/client.js:2629 | |
at moduleBody (http://localhost:7357/assets/test-support.js:1833) | |
at http://localhost:7357/assets/test-support.js:14773 | |
at createModule (http://localhost:7357/assets/test-support.js:1838) | |
at describeModule (http://localhost:7357/assets/test-support.js:1732) | |
at http://localhost:7357/assets/client.js:2644 | |
at http://localhost:7357/assets/vendor.js:150 | |
at tryFinally (http://localhost:7357/assets/vendor.js:30) | |
at http://localhost:7357/assets/vendor.js:156 | |
at http://localhost:7357/assets/test-loader.js:29 | |
at http://localhost:7357/assets/test-loader.js:21 | |
at http://localhost:7357/assets/test-loader.js:40 | |
at http://localhost:7357/assets/test-support.js:14840 |
I don't, looking into it. about beforeEach
, you mean they should be within the describe('#toggleSupport', function() {
block rather than the describeModule
?
@oliverbarnes yeah the way I have the beforeEach in the EJR blueprint is specifically for the Ember-QUnit test module setup and teardown. So with Mocha that is done differently, more BDD like syntax.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also do you know if the ember-mocha provides
this.container
?