The author of foo changes code to be module.exports = 'bar'; and releases it as 0.2.0. foo-user wants to use the latest foo so it updates its dependency, not expecting anything bad - foo's minor version number has been upgraded. In semantic versioning it means no breaking API changes.

foo-user is now broken!

Instead, before publishing new version to NPM, project foo can create a file in its project folder .dont-break.json with names of dependent projects to test

echo '["foo-user"]' > .dont-break.json

You can check if the current code breaks listed dependent project by running

dont-break

This will install each dependent project from .dont-break.json file into /tmp/dont-break... folder, will run the dependent's unit tests using npm test to make sure they work initially, then will copy the current project into the temp folder, overwriting the previous working version. Then it will run the tests again, throwing an exception if they stopped working.

Test command

You can specify a custom test command per dependent module. For example, to run grunt test for foo-module-name, but default command for module bar-name, list in .dont-break.json the following:

[
{
"name": "foo-module-name",
"test": "grunt test"
},
"bar-name"
]

Install command

You can specify a custom install command per dependent module. By default it's npm install. For example, this will use yarn add for foo-module-name, but keep default npm install for module bar-name:

[
{
"name": "foo-module-name",
"install": "yarn add"
},
"bar-name"
]

The name of dependent module will be added to given command, e.g. for above it will run yarn add foo-module-name.

Post-install command

Before testing the dependent package dont-break installs its dev dependencies via npm install command run from the dependency directory. If you need something more you can specify it via "postinstall" config parameter like this:

If specified this command will run first before pretesting the old version of lib (if pretest isn't disabled), then after installing current version of lib to dependent package. You can use $CURRENT_MODULE_DIR variable here which will be replaced with a path to current module:

Pre-testing with previous package version

By default dont-break first tests dependent module with its published version of current module, to make sure that it was working before the update. If this sounds excessive to you you can disable it with {"pretest": false} option:

Current module installation method

To test dependent package dont-break installs current module inside the dependent package directory. By default it uses npm install $CURRENT_MODULE_DIR. You can enter your command there, e.g. yarn add $CURRENT_MODULE_DIR. There are also pre-configured options npm-link and yarn-link. They can be helpful in some cases, e.g. if you need to use npm install or yarn in postinstall command. To use npm link method specify {"currentModuleInstall": "npm-link"}:

Env vars exported to called scripts

Following env vars are available for use in scripts called by executed steps:

$CURRENT_MODULE_DIR - directory of current module

$CURRENT_MODULE_NAME - name of current module as stated in its package.json

Installation timeout

You can specify a longer installation time out, in seconds, using CLI option

dont-break --timeout 30

Related

dont-break is the opposite of next-update that one can use to safely upgrade dependencies.

Setting up second CI for dont-break

I prefer to use a separate CI service specifically to test the current code against the dependent projects using dont-break. For example, the project boggle is setup this way. The unit tests are run on TravisCI using pretty standard .travis.yml file

MIT License

Copyright (c) 2014 Gleb Bahmutov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.