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.

cdkVirtualFor don't binding the content of my list in unit tests

See original GitHub issue

I am using the visrtual scroll strategy in my project, but in my unit tests I use this structure for research all tags <span> on my html list

let elements: DebugElement[] = fixture.debugElement.queryAll(By.css(‘span’)); expect(‘Today’).toBe(elements[0].nativeElement.textContent);

this is my html structure:

<cdk-virtual-scroll-viewport [itemSize]="50" [minBufferPx]="buffer" [maxBufferPx]="buffer * 1.5" cass="fullHeight" > <div #firstChild class="content"> <div *cdkVirtualFor="let demandaAgrupada of demandasAgrupadas; templateCacheSize: 1000" > <span *ngIf="demandaAgrupada.exibeCabecalho">{demandaAgrupada.grupoPeriodo}}/span> <pd-demanda-agrupada [demandaAgrupada]="demandaAgrupada" ></pd-demanda-grupada> </div> </div> </cdk-virtual-scroll-viewport>

When i use *ngFor instead of *cdkVirtualFor, my test works. But if I use *cdkVirtualFor, all content of my list isen’t binding and the div of *cdkVirtualFor, isen’t binding too this is my last element binding <!--bindings={↵ "ng-reflect-cdk-virtual-for-of": "[object Object],[object Object",↵ "ng-reflect-cdk-virtual-for-template-cache-size": "1000"↵}-->

there is a bug on unit tests with *cdkVirtualFor ?

sorry about my english, is not my first language

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
r-hannuschkacommented, Apr 4, 2019

Maybe a bit late, but @acutexyz solution was not working for me i solved this with:

    it("should render data from hypercube", fakeAsync(() => {
        ...
        fixture.autoDetectChanges();
        flush();  /* thats make it work */

        const listElements = fixture.debugElement.queryAll(By.css("div.lui-list__item"));
        expect(listElements.length).toBe(2);
    }));
0reactions
angular-automatic-lock-bot[bot]commented, Sep 10, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Virtual Scroll works fine on browser but fails Jasmine ...
I tried to incorporate Angular Virtual inside one of my component and it works fine as intended on browser. However, when I try...
Read more >
Getting to Know the Angular CDK Virtual Scroll Feature
Learn about virtual scrolling with angular CDK.
Read more >
Virtualize large lists with the Angular CDK - web.dev
Learn how to make large lists more responsive by implementing virtual scrolling with the Angular Component Dev Kit.
Read more >
How to use the infinite virtual scroll tool in the Angular ... - Morioh
You do not need Angular routing, but you have to choose CSS for styling. ... *cdkVirtualFor has a few variables you can use...
Read more >
cdkvirtualfor not working when we have less data to iterate ...
... your array as an immutable array. for example if i have an array of 100 items and run the below code on...
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