Skip to main content
Version: 5.x (Latest)

Teste End-to-End

Testing the integrity of React components by publishing in a private registry

The final stage of a react component is when it is being published and distributed. How can I ensure my packages won’t crash in production? This talk will help you to test your React components by publishing them to a private registry and running End-to-End tests against them.

End to End and Verdaccio

Alguns projetos organizam pacotes em repositórios multi-pacotes ou mono repositórios. End to End testing is a topic that usually is only relevant for User Interfaces, but from a Node.js perspective, publishing packages also need to be tested.

Tal abordagem tem sido realmente difícil de alcançar, considerando:

  • Populate canary packages on public services seems not to be a good idea
  • Some self-hosted OSS registries are too heavy
  • Offline environments (private networks)

O Verdaccio é um registro leve com zero configurações que se encaixa perfeitamente em qualquer fluxo de trabalho E2E + CI.


Ainda não há uma solução única, cada implementação parece ser específica de cada projeto, você pode verificar algumas delas clicando neste tópico.

Examples in Open Source

The following projects have examples using Verdaccio in Open Source

Bash Examples

This is the most simple example using Verdaccio in a bash script (extracted from create-react-app).


set -e


# start local registry
sh -c "mkdir -p $HOME/.config/verdaccio"
sh -c "cp --verbose /config.yaml $HOME/.config/verdaccio/config.yaml"
sh -c "nohup verdaccio --config $HOME/.config/verdaccio/config.yaml &>$tmp_registry_log &"
# wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)
# login so we can publish packages
sh -c "npm-auth-to-token -u test -p test -e -r $local_registry"
# Run nmp command
sh -c "npm --registry $local_registry publish"

Exemplos de Docker

Programtically Examples

Verdaccio module

Via CLI:

Node.js child_process examples

Example repositories