question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot test dxTemplate rendering

See original GitHub issue
devexteme version: 17.1.3
devextreme-angular version: 4.1.2

I am trying to test that the content of a popup was loaded correctly.

The component template looks like this: <dx-popup class="popup" [(visible)]="isVisible"> <div *dxTemplate="let data of 'content'"> <div>WTDFFFFFFFFFFFFFFFFFFFFFFFF</div> </div> </dx-popup>

The testing setup looks like this: TestBed.configureTestingModule({ imports: [ HttpModule, BrowserModule, FormsModule ], declarations: [ MyConfirmationComponent, DxPopupComponent, DxTemplateDirective ], schemas: [NO_ERRORS_SCHEMA], providers: [ PopupService,
] }); TestBed.compileComponents();

The element that is render does not contain the template text: WTDFFFFFFFFFFFFFFFFFFFFFFFF. It looks like this: <dx-popup _ngcontent-c4="" class="popup dx-overlay dx-popup dx-widget dx-visibility-change-handler" ng-reflect-visible="true"></dx-popup>

I can give more details if necessary. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
GoshaFightencommented, Jul 6, 2017

The content method returns a jQuery element. You can get a native element from a jQuery element in the following way:

const content: any = popupInstance.instance.content()[0];

But, jQuery selectors are much more powerful than native ones. So, you can’t use the :contains selector with a native element. But, I think you can give an ID or CSS class to your content to obtain it using the querySelector method. For example:

const content: any = popupInstance.instance.content()[0];
expect(content.querySelector('#content')).toBeTruthy();

<div *dxTemplate="let data of 'content'">
<div id="content">WTDFFFFFFFFFFFFFFFFFFFFFFFF</div>
</div>
0reactions
Spiticommented, Sep 22, 2017

thanks for the replies. I managed to implement it using your suggestion. Now I am trying to test the title of the popup which is in another dxtemplate, and I didn’t manage that. Do you have any suggestions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

dxTemplate doesn't work if it's specified in a custom Angular ...
Now I want to customize item template as below and it's not rendering items (please see attached screen shots).
Read more >
Shallow Testing in Angular - overwriting the template
The class-only tests can tell you about class behavior. They cannot tell you if the component is going to render properly, respond to...
Read more >
devextreme-angular - npm
DevExtreme-angular supports caching requests on the server in the server-side rendering mode. This avoids repeatedly requesting data from the ...
Read more >
NPM Dependencies in Pluggable Widget not working
js -> node_modules/devextreme-react/core/dx-template.js -> node_modules/devextreme-react/core/component-base. ... injectUrl/r<@http://localhost: ...
Read more >
Pushing element in empty datasource binded to the accordion ...
... [selectedIndex]=-1 [deferRendering]="true"> <div *dxTemplate="let company of 'title'"> ... app.service'; if(!/localhost/.test(document.location.host)) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found