Voltar ao radar Desenvolvimento com IA

Your unit tests are paying an unnecessary DOM tax

Open the test configuration of almost any front-end project and you’ll find one line that decides more about your CI bill than most of the code around it: environment: 'jsdom'. Unit and component tests for React, Vue, Angular, Svelte, and Solid apps rarely run in a real browser.

Open the test configuration of almost any front-end project and you’ll find one line that decides more about your CI bill than most of the code around it: environment: 'jsdom'. Unit and component tests for React, Vue, Angular, Svelte, and Solid apps rarely run in a real browser.

For most teams that library is jsdom, the long-standing, standards-minded default. A growing number use happy-dom, which is faster but less faithful. Few teams think about the choice again after the first npm install. They should, because the test DOM is often where a component suite spends a large share of its time, and because the two popular options force a trade that most teams don’t know they’re making.

Over the past months I measured this on real projects. Here is what I found, and what I built as a result.

A component test does very little work of its own. It creates elements, sets attributes, dispatches events, and reads back state. Every one of those steps is a call into the DOM implementation, and DOM APIs are chatty: a single high-level call can fan out into hundreds of internal ones.

To see how chatty, I built an open-source tracer, dom-api-tracer, that records which DOM APIs a test suite calls and how often. One example from those traces: a single getComputedStyle() call in jsdom triggered about 1,000 reads of Node and Element properties inside the library, because resolving styles means matching selectors against the tree. Testing libraries call getComputedStyle() constantly, for instance to decide whether an element is visible.

Multiply that by tens of thousands of tests and the DOM is no longer a detail. On Ant Design’s suite of React components, swapping the DOM implementation alone took a CI run from about 30 minutes to 6.7 minutes. Nothing else changed: same tests, same runner, same machine.

In context

  • Topic: Desarrollo con IA — Copilotos y agentes en el ciclo de desarrollo de software.
  • Source: InfoWorld
  • Published: 23/11/2026

Continue reading at the original source →

Excerpt published automatically by the site radar. The full text belongs to its publisher and is linked above.

Por que importa

Quando surge uma ferramenta que promete acelerar o desenvolvimento, a pergunta útil não é quanto código ela gera, e sim quanto trabalho gera rio abaixo. Testes, revisão, segurança, dívida técnica, incidentes: é ali que a promessa se paga ou se cobra.

Eu olho pela operação, não pela demonstração. A pergunta não é se o assistente escreve uma função correta, e sim se a equipe consegue sustentar seis meses depois o que produziu, com outras pessoas, sem o contexto original. Esse é o teste real e quase nunca aparece nos anúncios.

O que costuma dar errado

O problema aparece quando alguém aceita código que não entende por completo mas que passa nos testes. Funciona, entra em produção, e seis meses depois precisa ser alterado. Aí se descobre que ninguém na equipe consegue explicar por que está escrito assim, e a mudança pequena vira uma reescrita.

O que observar

  • O que acontece com os testes — gerar código sem gerar testes só empurra o problema para frente.
  • Por onde viaja o código-fonte quando se usa o assistente, e o que diz o contrato sobre isso.
  • O efeito sobre quem acaba de entrar na equipe, que é onde o critério se perde mais rápido.

Como leio esta publicação

O que eu pediria para medir não são linhas nem sugestões aceitas, e sim defeitos que chegam à produção e tempo de revisão por mudança. Se esses dois caem, a ferramenta serve. Se sobem enquanto a velocidade sobe, está se acumulando dívida que se paga com incidentes.

A notícia original está publicada em outro idioma; o trecho é citado como o veículo o entrega e o comentário é escrito em português.
Compartilhar

Comentários

Ainda não há comentários. O primeiro pode ser o seu.

Apenas texto, sem links. Não pedimos e-mail. Os comentários são revisados antes de serem publicados.

Está vivendo isso na sua equipe?

Abra o chat e me conte como estão lidando com isso. Tenho interesse em comparar notas.

Continuar lendo

Outras entradas do radar

Ver todas
Darinel Ortega Online · respondo ao longo do dia
Hoje
Olá. Aqui eu não vendo nada: isto é para trocar conhecimento sobre tecnologia.
Escreva o que quiser — pode mandar texto, imagens ou documentos. As mensagens chegam ao meu console e eu respondo por lá.
Você está escrevendo fora do horário. Eu leio assim que o dia começar.

Conversa aberta para compartilhar conhecimento. As mensagens chegam ao meu console e eu respondo por lá.

Vamos marcar uma conversa

Escolha o dia e a hora que funcionem para você. Trinta minutos, sem discurso comercial.

Videochamada

Para uma videochamada, peça por aqui que eu te mando o link da sessão.