Checks if the current version of your package would break dependent projects
Checks if the node module in the current folder breaks unit tests for specified dependent projects.
npm install -g dont-break
.dont-break.jsonfile in the root of your package, list module names that you would like to test as an array.
dont-breakany time to test latest version of each dependent module against the curent code
fooonly exports single variable
module.exports = 'foo';
foo-user only works if it gets string
foo from the module it depends on, like this:
var str = ;console;
foo has only a single release 0.1.0 that works for
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
foo-user is now broken!
Instead, before publishing new version to NPM, project
foo can create a file in its
.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
This will install each dependent project from
.dont-break.json file into
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.
In the example case, it will report something like this
$ dont-breakdependents [ 'foo-user' ]testing foo-userinstalling foo-userinstalled into /firstname.lastname@example.org testtests work in /email@example.com/lib/node_modules/foo-usercopied /Users/gleb/git/foo/* to /firstname.lastname@example.org/lib/node_modules/foo-user/node_modules/foonpm testnpm test returned 1test errors:AssertionError: value of foo should be "foo", but is barnpm ERR! Test failed. See above for more details.npm ERR! not ok code 0tests did not work in /email@example.com/lib/node_modules/foo-usercode 1FAIL: Current version break dependents
The message clearly tells you that the dependent projects as they are right now cannot upgrade to the version you are about to release.
You can specify GitHub repos as dependencies, because they most likely will
have tests. For example in
Picking projects to test manually is a judgement call. Dont-break can fetch top N most downloaded or most starred dependent modules and save the list.
dont-break --top-downloads <N>to find top N most downloaded dependent modules, save to
dont-break --top-starred <N>to find top N most starred dependent modules, save to
The above commands overwrite
You can specify a custom test command per dependent module. Separate the name of the module
from the test command using
: For example, to run
grunt test for
but default command for module
bar-name, list in
.dont-break.json the following:
foo-module-name: grunt testbar-name
You can also specify a longer installation time out, in seconds, using CLI option
dont-break --timeout 30
dont-break is the opposite of next-update that one can use to safely upgrade dependencies.
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
language: node_jsnode_js:- "0.12"- "4"branches:only:- masterbefore_script:- npm install -g grunt-cli
Then I setup a separate build service on CircleCi
just to run the
npm run dont-break command from the
dont-break on CircleCI, I created the
It should be clear what it does - installs
dont-break, and runs the npm script command.
machine:node:version: "0.12"dependencies:post:- npm install -g dont-breaktest:override:- npm run dont-break
To make the status visible, I included the CircleCI badges in the README file.
which produces the following:
Breaking dependencies? using dont-break
To see open github issues, use command
npm run issues
To see verbose log message, run with
DEBUG=dont-break ... environment
Author: Gleb Bahmutov © 2014
License: MIT - do anything with the code, but don't blame me if it does not work.
Spread the word: tweet, star on github, etc.
Support: if you find any problems with this module, email / tweet / open issue on Github
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.