emberjs / ember-mocha Goto Github PK
View Code? Open in Web Editor NEWMocha helpers for testing Ember.js applications
License: Apache License 2.0
Mocha helpers for testing Ember.js applications
License: Apache License 2.0
it('sets font when a font is selected', function(done) {
this.render(hbs`{{font-picker value=value}}`);
Ember.run(this.$('div'), 'click');
var self = this;
setTimeout(function() {
Ember.run($('.fontSelectUl:visible li:first'), 'click');
console.log('value', self.get('value')); // The component has already been destroyed!
done();
}, 250);
});
(Apologies if this isn't the right forum, trying to get Ember-CLI-Mocha up and running)
I have a fairly simple model User
which belongs to Shop
User = DS.Model.extend
shop: DS.belongsTo('shop')
Shop is a fairly complex model however. In my mocha test needs: []
block I end up specifying not only model:shop
(as expected), but also all of Shop's dependencies. If I don't then, I get:
Error: No model was found for 'foo' # (Foo is a relation of Shop)
at new Error (native)
at Error.EmberError (http://localhost:4200/assets/vendor.js:26714:23)
at Ember.Object.extend.modelFor (http://localhost:4200/assets/vendor.js:78459:19)
at typeForRelationshipMeta (http://localhost:4200/assets/vendor.js:75993:22)
at Function.<anonymous> (http://localhost:4200/assets/vendor.js:76415:48)
at Function.Mixin.create.eachComputedProperty (http://localhost:4200/assets/vendor.js:46465:20)
at Function.<anonymous> (http://localhost:4200/assets/vendor.js:76410:14)
at Descriptor.ComputedPropertyPrototype.get (http://localhost:4200/assets/vendor.js:25262:25)
at get (http://localhost:4200/assets/vendor.js:29864:21)
at findPossibleInverses (http://localhost:4200/assets/vendor.js:76337:33)
Specifying an inverse relation as follows doesn't seem to help:
Shop = DS.Model.extend
foo: DS.belongsTo('foo', inverse: 'shops')
Is there anyway to avoid this?
I'm trying to write an acceptance test for my index route, but it keeps failing on the most basic of functions.
describe('with feed items', function() {
beforeEach(function() {
// this.feedItems = server.createList('activity', 10, { verb: 'start discussion' });
this.users = server.createList('user', 5);
server.createList('group', 5);
server.createList('group-category', 5);
server.createList('base-forum', 5);
this.topics = server.createList('topic', 5);
this.post = server.createList('post', 5);
server.create('group', { id: 26, name: 'Snap!' });
server.createList('topic', 5, { groupId: 26 });
server.create('question');
server.createList('question-choice', 4);
server.createList('question-user-stat', 1);
server.createList('curated-item', 3);
});
it('has the correct path', function() {
visit('/');
andThen(() => {
expect(currentPath()).to.equal('index');
});
});
});
Gives me the error TypeError: currentPath is not a function
. However, it gives it to me as an error in the "after each" hook. The error for the test is that the timeout of Xms has exceeded (I've tried 2k, 5k, 10k). Additionally, when I replace currentPath() with 'index' (should easily pass) I get TypeError: app.testHelpers.wait is not a function
. And finally, when I add a console.log statement within the andThen, it doesn't fire until after the test is over. This all leads me to believe it's a problem with andThen. And thoughts or insights? Thanks!
We want to be able to test "anything". For example we want to test helpers and still access the "render" method. Does this question make sense?
Is there a way to configure setupTest so I can test a helper without having to use a component with an (almost) blank template? If not, can you please make setupTest generic or advise.
Hi Everyone,
I'm battling with an issue where I receive the following error when running an acceptance test on my registration code:
Error: Uncaught Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run
Here's my test:
import {
describe,
it,
beforeEach,
afterEach
}
from 'mocha';
import {
expect
}
from 'chai';
import sinon from 'sinon';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import config from '../../config/environment';
describe('Acceptance: Registration', function() {
var application;
var server;
///////////////////////////////////////////////////
/// Setup
///////////////////////////////////////////////////
beforeEach(function() {
// start the ember application
application = startApp();
// invalidate session if it exists
invalidateSession();
// create a fake server to intercept ajax requests
server = sinon.fakeServer.create();
server.respondImmediately = true;
// simulate successful login
server.respondWith('POST',
config.APP.API_URL + '/auth/login', loginSuccessResponse());
// simulate successful registration
server.respondWith('POST',
config.APP.API_URL + '/auth/register', registerSuccessResponse());
});
afterEach(function() {
// restore an alterations to the login endpoint
server.restore();
// tear down the application
Ember.run(application, 'destroy');
});
///////////////////////////////////////////////////
/// Tests
///////////////////////////////////////////////////
it('can register with valid information', function(done) {
visit('/signup');
fillIn('#businessName', 'test');
fillIn('#firstName', 'test');
fillIn('#lastName', 'test');
fillIn('#email', '[email protected]');
fillIn('#password', 'q1w2e3r4');
click('#submit');
andThen(function() {
expect(currentRouteName()).to.equal('login');
done();
});
});
And finally, here's the code that's running in the controller that's causing the hiccup:
signup: function() {
const _this = this;
const flashMessages = Ember.get(this, 'flashMessages');
// clear leftover flash messages
flashMessages.clearMessages();
// perform validation on the form
this.validate().then(function() {
// create the business record
var business = _this.store.createRecord('business', {
'name': _this.get('businessName')
});
// create the businessAccount record
var businessAccount = _this.store.createRecord('businessAccount', {});
// register the user
Ember.$.post('/auth/register', {
businessName: _this.get('businessName'),
firstName: _this.get('firstName'),
lastName: _this.get('lastName'),
email: _this.get('email'),
password: _this.get('password')
}).done(function(response) {
flashMessages.success('Thanks for signing up! Check your email for a link to verify your account.');
_this.transitionToRoute('login');
}).fail(function(error) {
flashMessages.warning(error);
}); // register()
}).catch(function() {
// display any errors returned by the client-side validator
var errors = _this.get('errors');
for (var e in errors) {
if (errors.hasOwnProperty(e) && errors[e].length > 0) {
flashMessages.warning(errors[e]);
}
}
}); // validate()
}
I realize that the call to Ember.$.post
is asynchronous, but it was my understanding that the Ember test helpers, such as click()
were of the asynchronous sort and andThen()
would wait until any async operations have been completed.
Regardless, I'm pulling my hair out a bit and would appreciate any help before it's all gone :)
Thanks in advance π
Best,
James
My team is seeing an issue with failing component integration tests (in this case non-block usage of the component) when running tests inside an ember-engine
with mocha/chai.
The test that is failing is the basic βit renders testβ
import { expect } from 'chai'
import {
describeComponent,
it
} from 'ember-mocha'
import hbs from 'htmlbars-inline-precompile'
describeComponent(
'sample-component',
'Integration: SampleComponentComponent',
{
integration: true
},
function () {
it('renders', function () {
this.render(hbs`{{sample-component}}`)
expect(this.$()).to.have.length(1)
})
}
)
The error is:
TypeError: Cannot read property 'lookup' of undefined
Here are the versions we are using:
package.json
"ember-cli": "~2.6.2"
"ember-cli-mocha": "0.10.4"
"ember-engines": "0.2.7"
bower.json
"ember": "~2.6.1"
"chai": "~2.3.0"
"ember-mocha": "0.8.11"
"ember-mocha-adapter": "~0.3.1"
"mocha": "~2.2.4"
When we changed the testing framework to qunit the test passed successfully:
"ember-cli-qunit": "2.2.1"
Thanks for the great project :)
Please write a short Getting Started guide in the README.
Required to add compat for Ember 2.0.0-beta.3.
With the following logs:
not ok 1 PhantomJS 1.9 - Global error: SyntaxError: Parse error at http://localhost:7357/assets/test-support.js, line 7347
---
Log: |
{ type: 'error',
text: 'SyntaxError: Parse error at http://localhost:7357/assets/test-support.js, line 7347\n' }
...
not ok 2 PhantomJS 1.9 - Global error: ReferenceError: Can't find variable: blanket at http://localhost:7357/assets/blanket-options.js, line 30
---
Log: |
{ type: 'error',
text: 'ReferenceError: Can\'t find variable: blanket at http://localhost:7357/assets/blanket-options.js, line 30\n' }
...
not ok 3 PhantomJS 1.9 - Global error: ReferenceError: Can't find variable: blanket at http://localhost:7357/assets/blanket-loader.js, line 4
---
Log: |
{ type: 'error',
text: 'ReferenceError: Can\'t find variable: blanket at http://localhost:7357/assets/blanket-loader.js, line 4\n' }
...
not ok 4 PhantomJS 1.9 - Global error: Error: Could not find module `ember-mocha` imported from `emedia-esmc/tests/test-helper` at http://localhost:7357/assets/vendor.js, line 180
---
Log: |
{ type: 'error',
text: 'Error: Could not find module `ember-mocha` imported from `emedia-esmc/tests/test-helper` at http://localhost:7357/assets/vendor.js, line 180\n' }
...
not ok 5 PhantomJS 1.9 - Global error: ReferenceError: Can't find variable: blanket at http://localhost:7357/assets/test-loader.js, line 119
---
Log: |
{ type: 'error',
text: 'ReferenceError: Can\'t find variable: blanket at http://localhost:7357/assets/test-loader.js, line 119\n' }
...
not ok 6 PhantomJS 1.9 - Global error: Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 16840
---
Log: |
{ type: 'error',
text: 'Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". at http://localhost:7357/assets/vendor.js, line 16840\n' }
...
Currently the pauseTest()
helper doesn't work properly with mocha due to its test timeouts. If you call this.timeout(0);
before using pauseTest()
it will work, but obviously it would be better if this could be done automatically.
Is it possible for us to overwrite the original pauseTest()
helper and add one that first calls this.timeout(0)
and the original code afterwards?
In order to avoid the deprecation warning about Ember.keys.
related: emberjs/ember-test-helpers#71
I'm having real problems trying to switch out the adapters for my test application. I'm using Ember CLI and Ember CLI Mocha.
It is better described on my Ember-CLI issue here -> ember-cli/ember-cli#3249
I've also tried
var attributes = Ember.merge({ApplicationAdapter:DS.FixtureAdapter.extend({})}, config.APP);
with no luck. :( Is there something I'm missing here? Or is this part of a larger issue?
It seems that the https://github.com/emberjs/ember-mocha-builds repository wasn't updated for the latest releases of this project.
Are people still using that at all? Do we have to support it forever?
I'm having trouble running an afterEach
block inside a describeComponent
block:
/* jshint expr:true */
import { expect } from 'chai';
import {
describeComponent,
afterEach,
it
} from 'ember-mocha';
import sinon from 'sinon';
describeComponent(
'table-header',
'TableHeaderComponent',
{
// Specify the other units that are required for this test
// needs: ['component:foo', 'helper:bar'],
unit: true
},
function () {
var sandbox = sinon.sandbox.create();
afterEach(function () {
sandbox.restore();
});
...
Fails with:
TypeError: (0 , _emberMocha.afterEach) is not a function
at http://localhost:7357/assets/tests.js:520:31
at Suite.moduleBody (http://localhost:7357/assets/test-support.js:2055:7)
at Object.context.describe.context.context (http://localhost:7357/assets/test-support.js:15276:12)
at Object.createModule (http://localhost:7357/assets/test-support.js:2060:13)
at describeComponent (http://localhost:7357/assets/test-support.js:1930:18)
at http://localhost:7357/assets/tests.js:513:37
at mod.state (http://localhost:7357/assets/vendor.js:157:29)
at tryFinally (http://localhost:7357/assets/vendor.js:37:14)
at requireModule (http://localhost:7357/assets/vendor.js:155:5)
at Object.TestLoader.require (http://localhost:7357/assets/test-loader.js:29:9)
but, the test works fine if I comment out the afterEach
block.
Is afterEach
not supported in describeComponent
blocks or am I doing something wrong here?
Thanks
Well.. The issue is when I switched from Qunit to Mocha, the acceptance tests where I "visit('/soandso')" no longer put the output into a window on the side as Qunit did.
Before mocha installation there was this in the test_helper.js file:
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
QUnit.config.urlConfig.push({ id: 'nocontainer', label: 'Hide container'});
var containerVisibility = QUnit.urlParams.nocontainer ? 'hidden' : 'visible';
document.getElementById('ember-testing-container').style.visibility = containerVisibility;
Could that have made the difference?
What do I have to do to put mocha acceptance testing html into it's own 'irfame' ??
I'd like to use the latest mocha in my project. It seems like the latest commit ( e570882 ) would fix that, but doesn't seemed to be pushed to bower.
It seems that there's a difference between ember-mocha and ember-qunit, in handling jquery-triggered DOM events in an integration: true
test.
DOM event triggers work in qunit:
But these events don't trigger in mocha:
integration: true
that I could easily build off ofPlease let me know if there's any additional information I can provide.
Using [email protected]
, generated an acceptance-test from the blueprint (ember g acceptance-test load-main-page
). It visits a nonexistent route and compares currentPath()
to a string:
describe('Acceptance: LoadMainPage', function() {
// ...
it('can visit /load-main-page', function() {
visit('/load-main-page');
andThen(function() {
expect(currentPath()).to.equal('load-main-page');
});
});
});
Expected to see the error message thrown by Ember:
Instead, see just [object Object]
:
This seems to be the case for all errors thrown by Ember.
Additional version information:
$ ember -v
version: 0.2.0-beta.1
node: 0.12.0
npm: 2.1.8
DEBUG: -------------------------------
DEBUG: Ember : 1.10.0
DEBUG: Ember Data : 1.0.0-beta.15
DEBUG: jQuery : 1.11.2
DEBUG: -------------------------------
I'm writing acceptance tests for a page that contains form validation (using ember-validations).
On submit, I call a validate()
method that triggers the form validation. That method returns a promise:
actions: {
submit() {
this.validate().then( ()=> {
this.sendAction('saveFoo', this.get('foo'));
});
}
}
The acceptance test verifying that the form shows actual error messages fails unless I rewrite the above code this way:
actions: {
submit() {
this.validate().then( ()=> {
this.sendAction('saveFoo', this.get('foo'));
}).catch( ()=> {});; // <= catch added here
}
}
So it looks like I have to swallow the promise rejection from ember-validations for my test to pass. The page works fine without the catch
, only the test fails.
Is there a way to tell mocha to ignore this error or is this expected?
For info, here it the test:
it.only('Inputting a foo less that 8 digits shows a client-side error', function () {
visit('/foo');
fillIn('.foo-input', '12345', 'input');
click('#btn-submit');
andThen(() => {
expect(currentPath()).to.equal('foo');
expect(find('.form-error').text()).to.include('too short');
});
});
Thanks!
The current version on NPM is about a month old. Could someone publish 0.6.0 on NPM?
Simple test, if I put a describe inside of a describe component I get test loaded failures.
Expose the integration test module from https://github.com/switchfly/ember-test-helpers/blob/master/lib/ember-test-helpers/test-module-for-integration.js
This may be a dumb question, but how would I go about changing the test reporter for ember-mocha? I'm not a big fan of the basic reporter being used by ember test
but can't seem to find documentation on how to go about changing it.
The set
method on a test case is undefined
when using needs. this simple test case passes when the need for the store is removed. this.subject
and this.render
still function in the scope of the test case
Test case:
import { expect } from 'chai';
import { describeComponent, it } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
describeComponent(
'my-component',
'Integration: MyComponent',
{
integration: true,
needs: ['store']
},
function() {
it('renders', function() {
this.set('model', {});
this.render( hbs`{{my-component model=model}}`);
expect(this.$('.my-component')).not.to.be.empty;
});
}
);
Results:
Integration: MyComponent renders
β 'undefined' is not a function (evaluating 'this.set('model', {})')
TypeError: 'undefined' is not a function (evaluating 'this.set('model', {})')
ref: ember-cli/ember-cli-mocha#80 (comment)
ember.debug.js:6440 DEBUG: -------------------------------
ember.debug.js:6440 DEBUG: Ember : 2.5.1
ember.debug.js:6440 DEBUG: Ember Data : 2.5.3
ember.debug.js:6440 DEBUG: jQuery : 2.1.4
ember.debug.js:6440 DEBUG: Ember Simple Auth : 1.1.0-beta.3
ember.debug.js:6440 DEBUG: -------------------------------
also in the console:
mocha.js:5937 Uncaught TypeError: Cannot read property 'replace' of undefined
exports.clean = function(str) {
str = str
.replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '')
.replace(/^function *\(.*\)\s*\{|\(.*\) *=> *\{?/, '')
.replace(/\s+\}$/, '');
str is undefined
no stack trace
repo: https://github.com/NullVoxPopuli/aeonvera-ui/tree/mocha-tests
travis: https://travis-ci.org/NullVoxPopuli/aeonvera-ui/jobs/131496096
@rwjblue I believe we just need to bump the dependency version and cut a release
This will allow users of ember-mocha to take advantage of the new public way to stub services in component integration tests
Can you export the context
keyword as well?
I have some utility classes that are not Mixins, Routes, Controllers, Models etc that I want to unit test. When I use describeModule
, I get
TypeError: Invalid fullName: `data-utils`, must be of the form `type:name`
I tried importing just a regular describe
but that was a no-go. Any help here would be greatly appreciated. Thanks!
describeModule
and friends accept a list of callbacks. E.g.
describeModule('component:x-foo', 'TestModule callbacks', {
beforeSetup: function() {},
setup: function() {},
teardown: function() { },
afterTeardown: function() {}
, function() {
// spec body
})
After using ember mocha for a while, I feel that using the callbacks mechanism is unnecessary and a result of limitations in qUnit leaking through the shared interface. The reason is because, unlike qUnit, mocha has a generalized setup and teardown api in the form of before{All,Each}
and after{All,Each}
hooks, I have yet to encounter a situation where they have not sufficed.
While they could remain optional via, they feel counter to the mocha way and so should not occupy such a prime portion of API real-estate. At the very least, I think that the ember cli blueprints should generate idiomatic mocha code that does setup and teardown inside before and after hooks.
Howdy @mattmcmanus & @rwjblue,
We've managed to get ember-mocha working nicely for our unit tests but have had no such luck on the acceptance tests π¦
We get the following error
Error: Could not find module `ember/load-initializers` imported from `my-cool-app/app`
For this basic test
/* jshint expr:true */
import {
describe,
it,
beforeEach,
afterEach
} from 'mocha';
import { expect } from 'chai';
import Ember from 'ember';
import startApp from '../helpers/start-app';
describe('Acceptance: Foo', function() {
var application;
beforeEach(function() {
application = startApp();
});
afterEach(function() {
Ember.run(application, 'destroy');
});
it('can visit /foo', function() {
visit('/foo');
andThen(function() {
expect(currentPath()).to.equal('foo');
});
});
});
Are acceptance tests supported and if not, do you have any suggestions for where we to start if we wanted to add support?
Hi, I'm trying to unit test a route using ember-mocha. On the guides they show how to do this with the default q-unit framework, but I'm not sure ember-mocha is acting the same way. In the guide example this.subject()
will return an instance of the module being tested. When I try to us emeber-mocha with a describeModule('route:someRoute'...) this.subject()
returns the class and not an instance of the route like expected.
Has a new build been released that includes the fallbackRegistry feature? Really need this functionality for a component integration test.
In many cases I'd like to use before
in a nested describe
or context
block but test helpers such as visit
are not defined.
beforeEach(function() {
visit("/"); // works fine
});
before(function() {
visit("/"); // visit is not defined
});
Related:
In mocha, we can set global timeout by adding test/mocha.opts
file:
--timeout 5000
Is there a way to do this in ember-mocha?
When you update dependencies with major version bumps, the least you can do is bump your minor version. That way you're not breaking the builds of people who only allow patch level changes.
chai 1.10 to 2.3.0 is a major version bump
mocha 2.1.0 to 2.2.4 is a minor version bump
ember-test-helpers 0.4.3 to 0.4.4 had a painful oversight
I'm having difficulties trying to test my custom serializer and I am looking for suggestions
app/serializer/company.js
import Ember from 'ember';
import DS from 'ember-data';
export default DS.ActiveModelSerializer.extend({
normalize: function(type, hash, property){
var json = Ember.merge(hash, {
links: {
reports: "reports"
}
});
return this._super(type, json, property);
}
});
tests/unit/serializers/company-test.js
/* jshint expr:true */
import { expect } from 'chai';
import {
describeModule,
it
} from 'ember-mocha';
describeModule(
'serializer:company',
'CompanySerializer',
{
// Specify the other units that are required for this test.
needs: ['model:company']
},
function() {
describe('#normalize', function(){
it('merges in a links hash', function(){
var serializer = this.subject();
var input = {
id: 2,
name: 'Acme Brick, Inc',
};
var Company = this.container.lookupFactory('model:company');
var results = serializer.normalize(Company, input, 'company');
expect(results.links).toEqual({
reports: "reports"
});
});
});
}
);
This gives me the follow error
CompanySerializer #normalize merges in a links hash
β Cannot read property 'modelFor' of undefined
TypeError: Cannot read property 'modelFor' of undefined
at ember$data$lib$system$relationship$meta$$typeForRelationshipMeta (http://localhost:7357/assets/vendor.js:81655:21)
at ember$data$lib$system$relationship$meta$$relationshipFromMeta (http://localhost:7357/assets/vendor.js:81667:15)
at Function.<anonymous> (http://localhost:7357/assets/vendor.js:81742:30)
at Function.ClassMixinProps.eachComputedProperty (http://localhost:7357/assets/vendor.js:43711:20)
at Function.<anonymous> (http://localhost:7357/assets/vendor.js:81739:12)
at Descriptor.ComputedPropertyPrototype.get (http://localhost:7357/assets/vendor.js:20246:25)
at get (http://localhost:7357/assets/vendor.js:25733:21)
at Function.ember$data$lib$system$model$model$$default.reopenClass.eachRelationship (http://localhost:7357/assets/vendor.js:82179:9)
at ember$data$lib$serializers$rest_serializer$$default.extend.normalizeRelationships (http://localhost:7357/assets/vendor.js:73855:16)
at ember$data$lib$serializers$json_serializer$$default.extend.normalize (http://localhost:7357/assets/vendor.js:73010:14)
I am thinking I might need to switch to using describeModel so that the store is loaded, but I ran into issues when I tried that too. I am on ember-mocha-0.6.2. Any suggestions would be greatly appreciated.
Question: If I were using ember-cli I would need to use the resolver from ember-cli/test/helpers/resolver like so:
import resolver from './helpers/resolver';
import { setResolver } from 'ember-mocha';
setResolver(resolver);
But If I'm using a globals release of ember-mocha say for rails + ember using Konacha do I even need to set a resolver using ember-mocha setResolver
?
related docs: http://guides.emberjs.com/v1.10.0/testing/unit-test-helpers/
I'd like to use this.container
in tests (ember-qunit) does this. I'm not sure if ember-mocha does the same.
Using Ember Mocha how can I access the container in an unit test?
This is the Unit test I have as a blueprint for an addon: https://github.com/pixelhandler/ember-jsonapi-resources/blob/master/blueprints/model-test/files/tests/unit/__path__/__test__.js however a consuming app may not use QUnit but ember-mocha instead. So I'd like to provide an example for testing with ember-mocha (addon and app not using ember-data).
cc/ @oliverbarnes
Basically, add a top level mocha
module so you can do:
import { describe, it } from 'mocha';
Similar to what was introduced in ember-qunit in https://github.com/rwjblue/ember-qunit/pull/132.
Problem:
While using ember-mocha
sometimes I accidentally check in it.only()
, and then our whole testing suite stops working >_>
One Potential Solution:
I couldn't find a jscs/eslint plugin that helps avoid this, so I made a dinky little bash script to test for it in the meantime lol. I'd love to convert it to a linter plugin, but I haven't learned that skill quite yet~
https://gist.github.com/caseywatts/221b353990abfec293aa7e54a397d508
Even though ember-mocha-builds
contains a tag for the v0.8.7 release of ember-mocha, the built assets there correspond to v0.8.6.
Notably, v0.8.6 has some issues regarding integration testing of components on ember canary that are fixed by v0.8.7, which is why is was investigating this in the first place :)
I'm using ember-jsonapi-resources instead of ED, and am having trouble using ember-mocha to test a model. Tried describeModel
, describeModule
, and describe
blocks, each time running into different problems loading the test and recognizing the helpers.
Looking at the source, though I'm still far from understanding what's going on there, I see DS
shows up quite a few times.
I was hoping to stick to mocha, being from rspec-world, by using simple describe
blocks and looking up the container directly to define the subjects of tests. Is there a way to do it?
Btw, are there plans to decouple EM from ED?
The docs are lacking. If you're new to ember, your docs aren't very understandable, there are some things inferred that I'm not familiar yet with ember. Yes I've looked at the Ember docs, still, ember-mocha doesn't help much in terms of install instructions.
also it looks like if I just install mocha, I can use it or do I still need to use this plugin? Maybe it's that webstorm is resoving mocha syntax because I've got mocha installed but still need to be using ember-mocha??
I ran ember install ember-cli-mocha
from terminal in the root folder of my ember app.
Then tried to setup a test like so:
/tests/my-test.js
import { describeModule, it } from 'ember-mocha';
let chai = require('chai'),
expect = chai.should();
describeModule('Companies - List', () => {
it('should display a list of companies ', () => {
expect($('tr.companies').to.have.length(2));
});
});
I don't know what I'm missing here. This test is in /tests
in my Ember app.
I get the error Unexpected token import
for my import line above after running mocha test
command in my terminal.
Obviously I'm not setting this up right, and I don't really know about how resolvers work with Ember yet, so your docs are lacking. How do I set this up correctly?
Did I setup my test ok? what am I missing?
And..how does this resolver work? Where do I actually put this code?
import resolver from './helpers/resolver';
import { setResolver } from 'ember-mocha';
setResolver(resolver);
pretend I've never used Ember...can you please give more details on what I'm missing or doing wrong here?
I'm not able to uses the ember helpers andThen
or click
when I use ember-mocha and ember-cli-mocha. This this a bug or a feature?
delete
ember-mocha/bower.json
has mocha
locked at 2.2.x
. Is there a reason for that?
There is at least one annoying bug that has been fixed in Mocha 2.3.x
.
Please upgrade.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.