What can possibly go wrong if I
don’t E2E test my packages?
Juan Picado
Core Team - Verdaccio
Node.js Meetup - Berlin, 2019
Senior Front-End Engineer at eBay
@jotadeveloper
@juanpicado
● Joined Verdaccio August 2016
● I love Open Source
● I do Node.js just for fun
● I like write documentation
Objective
● Brief Introduction to Verdaccio
● Create awareness about possible mistakes on
publishing packages
● How others are doing it?
● What measures we might take in order to avoid issues
How to install Verdaccio?
A lightweight proxy and private registry for Node.js
https://bit.ly/2KMkNW8
End to End Testing
End-to-end testing is a technique used to test whether the
entire application flow behaves as expected from start to
finish
https://ebaytech.berlin/100-percent-test-coverage-is-not-enough-3d733551bc3f
End to End Testing
Tests that simulate real user scenarios can easily help to
determine how a failing test would impact the user.
https://ebaytech.berlin/100-percent-test-coverage-is-not-enough-3d733551bc3f
Let’s translate this to Node.js publishing scenario
Provider
Consumer
What can possibly go wrong?
Awareness
Entry point is incorrect
Entry point is incorrect
Missing dependencies
● Flat node_modules structure issue
○ Using a sub-dependency provided by a dependency
Missing dependencies
● Dependencies removed from the registry
○ npmjs provides 72h window to remove pkgs (immutable)
○ private registries do not follow this rule (mutable)
https://github.com/ljharb
Missing dependencies
Jordan Harband
Dependencies holded by npmjs for security reasons
Missing dependencies
Packages just vanish from the public registry
Missing dependencies
Dependencies using git:// or relative locations
Missing dependencies
Other reasons
.npmignore is misconfigured
main entry point is included by default
Wrong compilation target (eg: @babel/env)
Other reasons
Excess of confidence on dependency bots
Other reasons
What other devs are doing?
@angular-cli
22k ⭐️
1,317,000 weekly downloads
@angular-cli
● Command Line Tool (scaffolds apps and libraries)
● Monorepo based on @angular-devkit
○ Similar to lerna structure
● Use yarn workspaces
● Custom build setup (no Jest or similar)
@angular-cli
@angular-cli
CircleCI - e2e-cli
@angular-cli
@angular-cli
CircleCI - e2e-cli
@angular-cli
Before was required mock dependencies as local tarballs
@angular-cli
● Special local build for E2E
● Using absolute paths for dependencies
○ No semver
○ No guarantee the local dependencies and their
transitive dependencies were used
● Unable to test the ng update command
● Some tests always tested last publish
Which issues angular cli was having?
@angular-cli
How @angular-cli solved the issue
@angular-cli
Verdaccio as devDependency
@angular-cli
Configuration
● Custom package access
● $all (any user)
● No proxy on private pkgs
@angular-cli
Verdaccio integration at @angular/cli
1. Spawn verdaccio
2. Custom build read all tests
3. Build local packages
4. Local Publish (+build) to Verdaccio (@angular/dev-kit)
5. Create a test project with ng CLI (fetching from verdaccio)
6. Run all tests in serie
@angular-cli
CircleCI - e2e-cli
@angular-cli
Spawn Verdaccio with JavaScript
@angular-cli
create-react-app
74k ⭐️
1,117,000 weekly downloads
@create-react-app
● Command Line Tool (scaffolds React apps)
● Monorepo based on Lerna
● Use yarn workspaces
● Use bash instead Javascript for E2E
@create-react-app
@create-react-app
@create-react-app
@create-react-app
● Prepare a workspace, copy, paste files
● npm link workaround
Which issues create-react-app was having?
@create-react-app
How create-react-app solved the issue
@create-react-app
Using bash to instantiate a server@create-react-app
Configuration
● Default package access
● $all (any user)
● Uplinks advanced
connections options for fetch
@create-react-app
Verdaccio integration at create-react-app
1. Bootstrap verdaccio (bash script)
2. Build all packages
3. Publish on Verdaccio with Lerna
4. Run npx create-react-app test-app
i. Build the app
ii. Run smoke tests
iii. Verify internal stuff and clean up
@create-react-app
Who else?
● CircleCI Integrated
● Use Verdaccio within a CircleCI Orbs
(https://circleci.com/orbs/)
11k ⭐️
1,041,000 weekly downloads
https://aurelia.io/
https://circleci.com/gh/aurelia/aurelia/37487
34k ⭐️
11,041,000 weekly downloads
https://babeljs.io/
34k ⭐️
11,041,000 weekly downloads
https://babeljs.io/
34k ⭐️
11,041,000 weekly downloads
https://babeljs.io/
🤓
Measures
● Intense Code Reviews (config files that affect packages)
● Publish to a local registry in each PR
● Perform a real installation
● Run smoke tests
● Ensure you are testing the user behaviour
● Rely real tooling (npm, npx, yarn, etc...)
What can possibly go wrong if I
don’t E2E test my packages?
Ship confidence
http://verdaccio.org
🤩🤩

What can possibly go wrong if i dont e2 e test my packages?

Editor's Notes

  • #31 Context about “Some tests always tested last publish”