Multi-remote snapshot throws an internal error when one instance has no element

Aperta Adatta ai principianti
#2,297 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@theluckystrike ci sta già lavorando.

Dal 8/10/2026.

  • #2319 di @theluckystrike — aperta
  • #2406 di @hoanle0126 — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
testing-qa

Direzione di ricerca

Inizia da src/matchers/snapshot.ts, in particolare da getMultiRemoteOuterHTML, e confronta il suo comportamento con getElementsPerInstance e getInstanceOrUndefined in src/util/multiRemoteUtils.ts. Aggiungi la copertura di unit test richiesta per gli elementi $() multi-remote mancanti in un'istanza, in toMatchSnapshot e toMatchInlineSnapshot; il lavoro è completo quando entrambi producono un errore del matcher che indica l'istanza mancante, senza registrare uno snapshot.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

toMatchSnapshot and toMatchInlineSnapshot throw an internal WebdriverIO error when a multi-remote element ($()) has no element on one instance. The other matchers give a correct matcher failure for the same subject.

Example: browserA and browserC find 3 header a links, and browserB finds 2. Then links[2] has no element on browserB.

const links = multiRemoteBrowser.$$('header a')

await expect(links[2]).toMatchInlineSnapshot('"x"')
// Error: Multi-remote object has no instance named "browserB"
Matcher on links[2] Result
toHaveText('1') Matcher failure: "browserB": undefined
toExist() Matcher failure: "browserB": "not exist"
.not.toExist() Matcher failure: browserA and browserC "exist"
toMatchInlineSnapshot('"x"') Error: Multi-remote object has no instance named "browserB"

Seen in an e2e run with WebdriverIO v10 (webdriverio/webdriverio#15846) and expect-webdriverio 8.0.0-alpha.2, in Chrome and Firefox.

Cause

getMultiRemoteOuterHTML calls getInstance(instance) for a single multi-remote element, and does not catch the error (line 104). getInstance() throws when the instance has no element.

The $$() path does not have this problem: it uses getElementsPerInstance, which catches the error with getInstanceOrUndefined.

Versions
  • main (8.0.0-alpha.2, e53a374d) with WebdriverIO v10: seen in an e2e run.
  • v7.0.1 with WebdriverIO v9: the same code is in getMultiRemoteOuterHTML, and the v9 getInstance() also throws (Multiremote object has no instance named). The v9 $$() gives undefined for an instance with fewer elements. I found this in the code, but I did not run it.
Proposal

Get the element of each instance with getInstanceOrUndefined. For an instance without an element, fail the assertion with a matcher message that names the instance, as toExist() does. Do not write a snapshot in this case, because the first run would then record a missing element as the expected value.

Add a unit test for a multi-remote $() that has no element on one instance, for toMatchSnapshot and toMatchInlineSnapshot.

When this is released, the multi-remote expect e2e spec of WebdriverIO v10 can cover this case.

Lingua principale
TypeScript
Stelle
86
Fork
67
Merge medio
9h 57m
PR unite (30g)
27

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di webdriverio/expect-webdriverio

Tutte le issue di webdriverio/expect-webdriverio

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.