# test-peer-range

> Test a package against the full range of major supported versions of a peer dependency

Latest version **3.0.0** (published 2022-08-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install test-peer-range
pnpm add test-peer-range
yarn add test-peer-range
bun add test-peer-range
```

Provides the command `test-peer-range`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-08-02 |
| First published | 2015-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 14 |
| Dependencies | 10 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | test, peer, plugin, ci, version, range, major |

## Links

- npm: https://www.npmjs.com/package/test-peer-range
- Repository: https://github.com/bendrucker/test-peer-range
- Homepage: https://github.com/bendrucker/test-peer-range#readme
- Issues: https://github.com/bendrucker/test-peer-range/issues
- npm.io page: https://npm.io/package/test-peer-range

## Dependencies (10)

- [meow](https://npm.io/package/meow.md) ~7.0.0
- [clout](https://npm.io/package/clout.md) ~3.0.0
- [semver](https://npm.io/package/semver.md) ^6.0.0
- [dot-prop](https://npm.io/package/dot-prop.md) ~5.2.0
- [eavesdrop](https://npm.io/package/eavesdrop.md) ~2.0.0
- [array-uniq](https://npm.io/package/array-uniq.md) ^2.0.0
- [mothership](https://npm.io/package/mothership.md) ~0.3.0
- [pkg-versions](https://npm.io/package/pkg-versions.md) ^2.0.0
- [run-versions](https://npm.io/package/run-versions.md) ^3.0.0
- [major-versions](https://npm.io/package/major-versions.md) ~2.2.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2022-08-02
- 2.0.0 — 2019-03-27
- 1.1.3 — 2018-11-15
- 1.1.2 — 2018-11-15
- 1.1.1 — 2018-11-15
- 1.1.0 — 2018-11-14
- 1.0.4 — 2018-11-13
- 1.0.3 — 2018-01-09
- 1.0.2 — 2018-01-09
- 1.0.1 — 2015-05-09
- 1.0.0 — 2015-05-09
- 0.1.0 — 2015-05-09

## README

# test-peer-range

> Test a package against the full range of major supported versions of a peer dependency

## Install

```
npm install --save-dev test-peer-range
```

## Usage

```sh
test-peer-range browserify
```

In `package.json`:

```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](https://semver.org/), 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.

## CLI

#### `test-peer-range <name>`

##### name

*Required*  
Type: `string`

The package name of the peer.

##### --versions

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`.

##### --command

Type: `string`  
Alias: `-c`  
Default: `test-main`

A command to run for each version. By default this is expected to be an npm script.

##### --npm

Type: `boolean`  
Default: `true`

Disable npm to run the `--command` directly.

##### --bail

Type: `boolean`  
Default: `false`

Exit immediately when any test fails. 

## API

#### `run(name, range, [options], callback)`

##### name

*Required*  
Type: `string`

The name of the peer to test against.

##### range

*Required*  
Type: `string`

The semver range of the peer versions to use for testing.

##### options

###### command

Type: `string`  
Default: `test-main`

The test command to run.

###### arguments

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`.

###### npm

Type: `boolean`  
Default: `true`

Run the command as an npm script.

###### bail

Type: `boolean`  
Default: `true`

Immediately end the run when a test fails.

##### callback

*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.

## License

MIT © [Ben Drucker](http://bendrucker.me)

---
_Source: https://npm.io/package/test-peer-range · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
