mardi 4 juin 2019

Auto-generated tests for an ember component fail for the block-form

(Ember 3.10) I have added the ember-drag-drop addon and then created a component as a wrapper for it, with a yield field that simply makes any content I pass to it draggable. However, the auto-generated test that was created using the 'ember generate component' command does not work with the component I created. The block form test fails because 'this.element.textContent.trim()' is empty and the assert expects the text written inside the block form.

The component works when I run the app, the component shows and it works just as expected. h However, I suspect I cannot access the textContent of the created element in the test function because of the nested structure of the components. I have attempted accessing the child element of the component, and it identifies a text object that has no text inside. I have also tried seeing what classes there are for the element, and it only sees 'ember-view' and nothing about the 'draggable-object' class I would expect to see if I use the draggable-object component from the addon. Maybe the thing that causes it to fail is the test not knowing about that addon, maybe I need to include it somehow? Although I expect it to be included if it can render a component that uses that addon without crashing.

The component I have generated is called "draggable", there is no JS functionality, just a handlebars template that looks like this:


  


The test for the block form looks like this:

await render(hbs`
      
        test
      
    `);

assert.equal(this.element.textContent.trim(), 'test');




Aucun commentaire:

Enregistrer un commentaire