Run oracles in a real browser (Vitest browser mode)

Abierto
#49 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
18/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, playwright
Área
testing

Línea de trabajo

Start with the imports in oracleProperty (node:async_hooks, node:fs, node:util) and with useOracleClock, then read oracle-gaps/capture-setup.mjs where ORACLE_GAPS_STATE is read through readFileSync. Running a test file under Vitest browser mode should show these failures, such as AsyncLocalStorage is not a constructor. Done means a browser-safe entry imports and runs in browser mode, and the gap check either runs there or is documented as unsupported.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

An oracle for DOM code must run in jsdom today, so its driver supplies the
browser facts that jsdom lacks: layout, scroll positions, the targets where
scroll events fire, ResizeObserver notifications, and computed styles. When
the driver's stand-in and production rest on the same wrong belief about the
browser, the oracle passes, and only a human or a real browser finds the bug.

We hit this three times in one pull request (react-headroom):

  • The stand-in notified a ResizeObserver on any size change. Chrome notifies
    a content-box observer only when the content box changes, so a header that
    changes only its padding kept a stale height.
  • The stand-in decided that a body with overflow-y: auto scrolls itself.
    With html { overflow-y: scroll } body { overflow-x: hidden }, Chrome
    computes the body's overflow-y as auto, but the body grows with its
    content and the page scrolls.
  • The stand-in gave a body the viewport's height. In Chrome, a body that does
    not scroll itself grows with the page.

We checked each fact by hand in headless Chrome. An oracle that runs in
Chrome would have checked them on every run.

What stops it at 4749f61

  1. oracleProperty imports node:async_hooks (AsyncLocalStorage for probe
    windows), node:fs (appendFileSync) and node:util (inspect,
    isDeepStrictEqual, types). In Vitest browser mode the test file fails
    to import: AsyncLocalStorage is not a constructor.
  2. The gap check's setup file (oracle-gaps/capture-setup.mjs) reads its run
    state from process.env.ORACLE_GAPS_STATE with readFileSync. In browser
    mode, setup files run in the page.

Request

  • Let oracleProperty and useOracleClock run in Vitest browser mode, for
    example with a browser-safe entry that replaces AsyncLocalStorage, fs
    and util with browser equivalents or leaves those features out.
  • Let oracle-gaps run an oracle in browser mode, or document that it cannot,
    and recommend a pattern: for example, an oracle that runs in Chrome for its
    laws, and the same oracle in jsdom for the gap check.

Workaround we considered

Keep the oracle in Node and drive a Chrome page through Playwright: the
driver sends each history to the page, which runs it against a bundle of
production and returns the observations. This needs a page bundle, a
page-side clock in place of useOracleClock, and two copies of the driver
environment. The gap check still cannot mutate the code in the page.

Lenguaje dominante
JavaScript
Estrellas
5
Forks
1
Merge medio
8 h 31 min
PR fusionados (30 d)
60

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TanStack/oracles

Todos los issues de TanStack/oracles

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.