useVirtualizer not working in Vue Test Utils

Offen
#709 2 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
typescript
Bereich
frontend, testing

Rechercherichtung

Beginne mit der Vue-Beispielkomponente auf Grundlage von RowVirtualizerFixed.vue und der in diesem Issue beschriebenen Reproduktion RowVirtualizerFixed.test.ts. Führe den Vitest-Test aus und untersuche wrapper.html zusammen mit der gerenderten Ausgabe des Virtualizers. Erledigt ist die Aufgabe, wenn die Testumgebung virtualisierte Zeilen im wrapper HTML rendert, entsprechend dem Verhalten der App.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug

The virtualizer doesn't seem to work when used in Vue Test Utils.

Your minimal, reproducible example
Steps to reproduce
  1. Create a new vite app with vue + ts template
    npm create vite@latest

  2. Install vitest and vue test utils
    npm i vitest
    npm i @vue/test-utils

  3. Create a new component based on any vue tanstack virtual example, I tried with: -> RowVirtualizerFixed.vue in fixed example

  4. Create a new basic test file RowVirtualizerFixed.test.ts and log the wrapper's html:

import { mount } from '@vue/test-utils'
import { describe, it } from 'vitest'
import VirtualRowsExample from './VirtualRowsExample.vue'

describe('VirtualRowsExample', () => {
  it('should render virtualized rows', () => {
    const wrapper = mount(VirtualRowsExample)
    console.log(wrapper.html())
  })
})

  1. Run the tests
  2. As you will see the wrapper won't print any html where the rows should be visible

Looks like rowVirtualizer.value.getVirtualItems is not returning any row

<div class="List" style="height: 200px; width: 400px; overflow: auto;">
  <div style="height: 350000px; width: 100%; position: relative;"></div>
</div>

The component looks fine when used in the app

Expected behavior

Some Rows should be printed in wrapper's html

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Windows

tanstack-virtual version

3.0.4

TypeScript version

4.9.3

Additional context

No response

Terms & Code of Conduct
  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Vorherrschende Sprache
TypeScript
Sterne
7.2k
Forks
495
Ø Merge
15 Std. 11 Min.
Gemergte PRs (30 T.)
17

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TanStack/virtual

Alle Issues in TanStack/virtual

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.