Test a package against the full range of major supported versions of a peer dependency
npm install --save-dev test-peer-range
test-peer-range browserify
In package.json
:
{
"name": "transformify",
"description": "A browserify transform",
"scripts": {
"test": "test-peer-range browserify",
"test-main": "node test.js"
},
"devDependencies": {
"browserify": "16",
"test-peer-range": "*"
},
"peerDependencies": {
"browserify": ">= 14"
}
}
The program will execute test-main
for each major version (e.g. 14, 15, 16) of the peer. This is useful for maintaining backward compatibility for plugins. As long as the peer dependency follows semver, you can be confident that your code works on old versions while developing against a more recent line.
Arguments are passed through, so running npm test -- --inspect
would result in node test.js --inspect
as your test command.
Required
Type: string
The package name of the peer.
Type: array[string]
Alias: -v
Default: test-main
Additional versions to test, on top of major versions specified in peerDependencies
. Repeat this flag to specify multiple versions, e.g. -v 1.2.3 -v 4.5.6
.
Type: string
Alias: -c
Default: test-main
A command to run for each version. By default this is expected to be an npm script.
Type: boolean
Default: true
Disable npm to run the --command
directly.
Type: boolean
Default: false
Exit immediately when any test fails.
Required
Type: string
The name of the peer to test against.
Required
Type: string
The semver range of the peer versions to use for testing.
Type: string
Default: test-main
The test command to run.
Type: array[string]
Default: []
Additional command line arguments to pass to the command. For npm scripts, these will be passed to the script itself, not npm run
.
Type: boolean
Default: true
Run the command as an npm script.
Type: boolean
Default: true
Immediately end the run when a test fails.
Required
Type: function
Arguments: err, results[{version, passed}]
The callback to call when done. Receives an array of objects with version (string
) and passed (integer
) properties.
MIT © Ben Drucker