1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/website/versioned_docs/version-6.x/e2e.md
2024-09-26 21:05:10 +02:00

5.7 KiB
Raw Blame History

id title
e2e End to End testing

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 wont 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

Some projects organize packages in multi-packages repositories or monorepos. 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.

Such approach has been really hard to achieve considering:

  • 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)

Verdaccio is a lightweight registry with zero-configuration that fits perfectly in any E2E + CI workflow.

Implementation

There is no a silver bullet yet, each implementation seems to be specific for each project, you can check some of them in the following thread clicking here.

Examples in Open Source

The following projects have examples using Verdaccio in Open Source

Bash Examples

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

#!/bin/sh

set -e

local_registry="http://0.0.0.0:4873"

# start local registry
tmp_registry_log=`mktemp`
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 test@test.com -r $local_registry"
# Run nmp command
sh -c "npm --registry $local_registry publish"

Docker Examples

Programmatic Examples

Verdaccio module

Via CLI:

Node.js child_process examples

Example repositories