0
votes

I have an Ember.js application with Ember-CLI and using Firebase. When I run /tests the only error I get is the following:

Error: Please set the firebase property on the adapter. at init (http://localhost:4200/assets/vendor.js:99854:15) (...etc.)

My application.js adapter code is the standard following emberfire install:

import Ember from 'ember';
import FirebaseAdapter from 'emberfire/adapters/firebase';

const { inject } = Ember;

export default FirebaseAdapter.extend({
  firebase: inject.service(),
});

and my firebase: URL is set in the environment.js file. Can anyone point me in the direction of where the problem might be? The application itself runs fine. I realise this is an error response built into the init function of emberfire, but that doesn't help me! I'm sure it must be something small and obvious to the initiated but I'm still on the learning curve...

Thanks in advance.

Ember 1.13.7 - Ember Data 1.13.8 - Firebase 2.3.0 - EmberFire 1.5.0 - jQuery 1.11.3

3

3 Answers

2
votes

I think that specifying the missing unit with a needs property is more appropriate in this case, as the adapter is failing to inject the Firebase service.

import { moduleFor, test } from 'ember-qunit';

moduleFor('adapter:application', 'Unit | Adapter | application', {
  // Specify the other units that are required for this test.
  needs: ['service:firebase']
});

// Replace this with your real tests.
test('it exists', function(assert) {
  let adapter = this.subject();
  assert.ok(adapter);
});

Hope this helps with your tests.

0
votes

You have to inject the Configuration as well since the firebase service needs the config.

export default {
  create(application) {
    const config = getOwner(application)._lookupFactory('config:environment');

so the correct answer is:

import { moduleFor, test } from 'ember-qunit';

moduleFor('adapter:application', 'Unit | Adapter | application', {
  // Specify the other units that are required for this test.
  needs: ['service:firebase', 'config:environment']
});

// Replace this with your real tests.
test('it exists', function(assert) {
  let adapter = this.subject();
  assert.ok(adapter);
});
-1
votes

I solved this by modifying the tests/unit/adapters/application-test.js file to be:

import { moduleFor, test } from 'ember-qunit';
import FirebaseAdapter from 'emberfire/adapters/firebase';

moduleFor('adapter:application', 'Unit | Adapter | application', {
  // Specify the other units that are required for this test.
  // needs: ['serializer:foo']
});

// Replace this with your real tests.
test('it exists', function(assert) {
  var adapter = FirebaseAdapter; //this.subject();
  assert.ok(adapter);
});

Hope that helps someone else!