1

I have a component that calls something like:

this.get('store')
  .findAll('calendar-event')
  .then((data) => {
    // do stuff
  });

However, when I replace findAll() with query() it breaks my integration testing.

this.get('store')
  .query('calendar-event', { some_stuff: [596] })
  .then((data) => {
    // do stuff
  });

The application in the web browser via ember server continues to function correctly. However: no luck with integration testing. Error I get is: TypeError: Cannot read property 'setObjects' of null

Integration test looks like:

import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import moment from 'moment';

import startMirage from '../../helpers/setup-mirage-for-integration';

moduleForComponent('main-calendar', 'Integration | Component | main calendar', {
  integration: true,
  beforeEach() {
    startMirage(this.container);
  },
  afterEach() {
    window.server.shutdown();
  }
});

test('it renders', function (assert) {
  this.render(hbs`{{main-calendar}}`);
  assert.equal(this.$('.col-sm.text-center').text().trim(), moment().format('MMMM YYYY'));
});

Any ideas why it would render with the server but not on the integration testing side of things.

thornomad
  • 6,707
  • 10
  • 53
  • 78
  • 1
    With `ember server` is Mirage also running or are you proxying to a backend? You can use `server.logging = true` in the beginning of your test to make sure the HTTP response is correct. Lastly, you may need to use `wait()` if your integration test is async. – Sam Selikoff Aug 04 '17 at 14:08
  • 1
    Hi @SamSelikoff - `ember server` is using mirage (works) and `ember server --proxy` uses the real API (also works); however `ember test --server` is what throws the errors. However, it was `wait()` that did the trick. I can answer my own question or if you want to move your answer there I will mark it as the accepted one. Bonus points for why `findAll()` doesn't need `wait()` but `query()` does! – thornomad Aug 04 '17 at 23:13

0 Answers0