test requirements for published npm packages

34 views Asked by At

I publish some rudimentary JavaScript packages in npmjs mainly for the convenience of importing them from my projects wherever I may need them.

One of them (a minmax engine with alpha-beta pruning), let's call it package-foo, may be useful to a broader audience.

My question has to do with the expectations around tests. If somebody clones the gihtub repo of the package, they will be able to run npm test (to run the Mocha tests) or npm run flow (for static type analysis using Flow). However, when they install my package using npm to use it in one of their own projects (by listing it in their package.json file), they are not able to cd to the node_modules/package-foo directory and successfully run npm test there.

Is it a requirement / best practice that tests for a package can be executed from the node_modules sub-directory or are tests meant to work only in a development setting (i.e. in a cloned github repo)?

Experimenting a little with packages that I see in my own node_modules directory I found none where I was able to successfully run npm test. What are best practices / expectations of user programmers in this area?

0

There are 0 answers