How to mock an Ember-CLI service in an acceptance test?

Short version of the solution: your registered mock service must have a different service:name than the “real” service you’re trying to mock. Acceptance test: import Ember from ’ember’; import { module, test } from ‘qunit’; import startApp from ‘container-doubling/tests/helpers/start-app’; var application; let speakerMock = Ember.Service.extend({ speak: function() { console.log(“Acceptance Mock!”); } }); module(‘Acceptance | acceptance … Read more

{{content-for ‘head’}} Ember-cli

It was recently added to ember-cli based on this discussion. Here is the relevant code from the commit: EmberApp.prototype.contentFor = function(config, match, type) { var content = []; if (type === ‘head’) { content.push(calculateBaseTag(config)); content.push(‘<meta name=”‘ + config.modulePrefix + ‘/config/environment” ‘ + ‘content=”‘ + escape(JSON.stringify(config)) + ‘”>’); } content = this.project.addons.reduce(function(content, addon) { if (addon.contentFor) … Read more

How to use third party npm packages with ember cli app

The easiest and recommended answer is to use ember-browserify. (as support for bower packages will be removed in the future.) This is an example for using the npm package dexie within an Ember CLI app. Install browserify: npm install ember-browserify –save-dev Install dexie (or whatever module you need): npm install dexie –save-dev Import the module … Read more

Ember CLI testing complicated model relationships

If you are using Ember default ‘Ember-QUnit’ then you have to list all the models in needs. But there is an alternative for testing which I am using i.e. ember-data-factory-guy. This is used to create factory instead of fixture data when testing Model, component, controller etc. You can go through it. https://github.com/danielspaniel/ember-data-factory-guy

Getting “Uncaught Error: Assertion Failed: Ember Views require jQuery between 1.7 and 2.1” with app created through ember-cli

This is a bug due to a new version of jQuery which ember is not yet able to handle. For now you can change the following line in your bower.json file. Then run bower install and it should work. “jquery”: “^1.11.3”, to “jquery”: “1.11.3”, A new version of ember.js is imminent which should fix this.

Violating Content Security Policy directive after ember-cli 0.0.47 upgrade

After reading some docs at http://content-security-policy.com/ and https://github.com/rwjblue/ember-cli-content-security-policy, I added some policies to my config/environment.js file like so: module.exports = function(environment) { var ENV = { contentSecurityPolicy: { ‘default-src’: “‘none'”, ‘script-src’: “‘self’ ‘unsafe-inline’ ‘unsafe-eval’ use.typekit.net connect.facebook.net maps.googleapis.com maps.gstatic.com”, ‘font-src’: “‘self’ data: use.typekit.net”, ‘connect-src’: “‘self'”, ‘img-src’: “‘self’ www.facebook.com p.typekit.net”, ‘style-src’: “‘self’ ‘unsafe-inline’ use.typekit.net”, ‘frame-src’: “s-static.ak.facebook.com static.ak.facebook.com … Read more

Recommended way to include bootstrap library in Ember.JS ember-cli App

BASH: bower install –save bootstrap Brocfile.js: app.import(‘vendor/bootstrap/dist/js/bootstrap.js’); app.import(‘vendor/bootstrap/dist/css/bootstrap.css’); The JS will be added to the app.js, which is linked by default, and the CSS will be added to assets/vendor.css, which as of May 14th, is also added by default. For reference: http://www.ember-cli.com/#managing-dependencies In response to @Joe’s question surrounding fonts and other assets, I was unable … Read more

ember-cli-code-coverage mocha showing 0% coverage when there are tests

Few well integrated tools to establish accurate code coverage for ember-cli apps exist. (something like Istanbul for everything in app/) We ended up avoiding ember-cli-blanket and writing a rudimentary istanbul 78 integration with testem. Basically, it calls the istanbul cli against the single JS file output by ember build. Imprecise but consistent. We’ve used in … Read more

tech