vendredi 4 mars 2016

Why do my ember tests give me TypeError: 'undefined' is not a function?

here is the error from the ember test --serv output:

Integration | Component | date-time-input: it renders
    ✘ TypeError: 'undefined' is not a function (evaluating 'elem.getAttribute( name )')
        http://localhost:7357/assets/vendor.js:1685

This happens with all of my Integration and Acceptance tests.

How do I debug this error without a decent stack trace? is there a way to configure ember to give me a decent stack trace?

Here is the test for the above error:

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

moduleForComponent('date-time-input',
  'Integration | Component | date-time-input', {
    integration: true,
  });

test('it renders', function(assert) {
  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });
  let two = Ember.Object.extend({
    someDate: null,
  });
  this.set('two', two);
  this.render(hbs`{{date-time-input model=two field='someDate'}}`);

  assert.notEqual(this.$().text().indexOf('2016'), -1);
});

and the corresponding component

import Ember from 'ember';

export default Ember.Helper.helper(function (params) {
  let date = params[0];
  let format = params[1];
  let allowBlank = params[2];

  if (!Ember.isPresent(date) && allowBlank) {
    return '';
  }

  return moment(date).format(format);
});

here is my repo, in case anyone is curious: http://ift.tt/1QxepeO




Aucun commentaire:

Enregistrer un commentaire