DEV Community

Cover image for Testing npm packages before publishing

Testing npm packages before publishing

Carl Vitullo on July 27, 2018

Photo by Erol Ahmed on Unsplash When developing an npm package, you have to confirm that it can actually be used. It's great if tests pass, exampl...
Collapse
 
gmartigny profile image
Guillaume Martigny

Nice article.

Just to add my 2 cents:
If you're building a complex package, you could want to split part of it into multiple sub-packages. It's (IMO) a clean programming structure that every logic has it's own file and require only what's necessary.
But doing dozen of npm link is maddening. And Lerna is such a great help with that.
It allow you to easily manage sub-packages from adding dependencies, running scripts or publishing.

Collapse
 
ben profile image
Ben Halpern

Super useful, thanks for the post Carl!

Collapse
 
svale profile image
Svale Fossåskaret

Very helpful! npm pack was new to me and just what I needed to verify changes to the files-field didn't break anything. Thanks!

Collapse
 
tamb profile image
Tamb

Did not know about npm pack. That's awesome! Thank you!

Collapse
 
margaretkrutikova profile image
Margarita Krutikova

This just solved the problem I have been battling in ages, and I can finally go to sleep now 😅
Thanks for the amazing article!

Collapse
 
qwertie_63 profile image
David Piepgrass

Why not use testpack-cli? It automates the process of running your unit tests against the package produced by npm pack.