Some projects organize packages in multi-packages repositories or monorepos. E2E 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.
Solution: a local npm registry. https://t.co/kvcyVANVSK— Dan Abramov (@dan_abramov) 11 de enero de 2018
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.
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.
Example using Bash
This is the most simple example using Verdaccio in a bash script (extracted from create-react-app).
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 email@example.com -r $local_registry" # Run nmp command sh -c "npm --registry $local_registry publish"
Whom are using it for E2E?
- create-react-app (+64k ⭐️)
- Storybook (+34k ⭐️)
- Gatsby (+31k ⭐️) WIP #8791 #11525
- Uppy (+15k ⭐️)
- Aurelia Framework (+10k ⭐️)
- bit (+6k ⭐️)
- pnpm (+5k ⭐️)
- Mozilla Neutrino (+3k ⭐️)
- Hyperledger Composer (+1.6k ⭐️)
- Wix Yoshi
Babel.js might be interested on integrate Verdaccio in their workflow, if you want to contribute, check this ticket.
Thinking of using verdaccio to test @lernajs v3 (+use this generally), as it's hard to know if a publish will be successful. Would like us to fix an issue where we would like to compile Babel using itself before it's published (as we self-host but from latest npm) as a smoke test— Henry Zhu (@left_pad) 28 de septiembre de 2018