Is it acceptable to create tests relying on docker for a node.js module?
I currently have a module which needs to be tested in different scenarios.
But to improve the tests I have a lot of file copying and
child-process execs to do.
Maybe Docker would be a good solution to run the tests, but this would add a dependency on Docker.
Also I haven’t seen packages relying on docker for such scenarios so far.
So for an
npm package, would it be acceptable to publish a package with tests relying on docker?
One Solution collect form web for “Is it acceptable to create tests relying on docker for a node.js module?”
I’d first think about your intended audience – how likely is it that users downloading your module will already have Docker installed?
If your module is already Docker related, it’s fare to assume most users will already have Docker. If it’s a util for handling React routes, probably not.
You should also consider the impact of not testing certain difficult to test features vs the difficulty or complexity created by testing them.
For the vast majority of people using npm modules, they rarely run the tests anyway. Running tests is reserved for people who actively want to develop and contribute to modules.
One common approach which might fit your problem is to include the Docker setup and tests in the project but exclude them from the actual module itself. In your
package.json for the module, you can include a
files property which defines which files should actually be included when publishing the module.
With this approach you can setup and run tests in a way that suits you – and is available for any helpful contributors if they want it – but doesn’t burden day-to-day users with extra setup they don’t need.